Commit 117d5556 authored by yangxiaodong's avatar yangxiaodong

refactor

parent 8106a7d1
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Cap.Consistency.Infrastructure;
using Cap.Consistency.Store;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.EntityFrameworkCore;
......@@ -20,7 +21,7 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
services
.AddDbContext<ConsistencyDbContext>(o => o.UseSqlServer(fixture.ConnectionString))
.AddConsistency<ConsistencyMessage>()
.AddConsistency()
.AddEntityFrameworkStores<ConsistencyDbContext>();
services.AddLogging();
......@@ -39,8 +40,8 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public async Task EnsureStartupUsageWorks() {
var messageStore = _builder.ApplicationServices.GetRequiredService<IConsistencyMessageStore<ConsistencyMessage>>();
var messageManager = _builder.ApplicationServices.GetRequiredService<ConsistencyMessageManager<ConsistencyMessage>>();
var messageStore = _builder.ApplicationServices.GetRequiredService<IConsistencyMessageStore>();
var messageManager = _builder.ApplicationServices.GetRequiredService<ConsistencyMessageManager>();
Assert.NotNull(messageStore);
Assert.NotNull(messageManager);
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Cap.Consistency.Infrastructure;
using Cap.Consistency.Store;
using Cap.Consistency.Test;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
......@@ -24,7 +25,7 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
return TestPlatformHelper.IsMono || !TestPlatformHelper.IsWindows;
}
public class ApplicationDbContext : ConsistencyDbContext<ApplicationMessage, string>
public class ApplicationDbContext : ConsistencyDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
}
......@@ -95,7 +96,7 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
}
protected override void AddMessageStore(IServiceCollection services, object context = null) {
services.AddSingleton<IConsistencyMessageStore<ConsistencyMessage>>(new ConsistencyMessageStore<ConsistencyMessage>((ConsistencyDbContext)context));
services.AddSingleton<IConsistencyMessageStore>(new ConsistencyMessageStore<ConsistencyDbContext>((ConsistencyDbContext)context));
}
}
......
using System;
using Cap.Consistency.Infrastructure;
using Cap.Consistency.Store;
using Cap.Consistency.Test;
using Microsoft.AspNetCore.Testing;
using Microsoft.EntityFrameworkCore;
......@@ -17,7 +18,7 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
}
protected override void AddMessageStore(IServiceCollection services, object context = null) {
services.AddSingleton<IConsistencyMessageStore<MessageWithGenerics>>(new MessageStoreWithGenerics((ContextWithGenerics)context));
services.AddSingleton<IConsistencyMessageStore>(new MessageStoreWithGenerics((ContextWithGenerics)context));
}
protected override object CreateTestContext() {
......@@ -48,15 +49,15 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
{
}
public class MessageStoreWithGenerics : ConsistencyMessageStore<MessageWithGenerics>
public class MessageStoreWithGenerics : ConsistencyMessageStore<ContextWithGenerics>
{
public MessageStoreWithGenerics(DbContext context) : base(context) {
public MessageStoreWithGenerics(ContextWithGenerics context) : base(context) {
}
}
public class ContextWithGenerics : ConsistencyDbContext<MessageWithGenerics, string>
public class ContextWithGenerics : ConsistencyDbContext
{
public ContextWithGenerics(DbContextOptions options) : base(options) {
public ContextWithGenerics() {
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment