From ce7d76e4f05d70d0a53a676015bc346bcde412be Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Tue, 23 May 2017 16:58:38 +0800 Subject: [PATCH] refactor --- Cap.sln | 11 ++++++++++- ...Consistency.EntityFrameworkCore.Test.csproj | 4 ++++ .../DefaultPocoTest.cs | 1 + .../MessageStoreTest.cs | 1 + .../MessageStoreWithGenericsTest.cs | 1 + .../Cap.Consistency.Test.csproj | 4 ++++ .../ConsistencyMessageManagerTest.cs | 5 +++-- test/Shared/MessageManagerTestBase.cs | 5 +++-- test/Shared/TestConsistencyMessage.cs | 18 +++--------------- 9 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Cap.sln b/Cap.sln index ac08b09..08e2650 100644 --- a/Cap.sln +++ b/Cap.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26430.6 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9B2AE124-6636-4DE9-83A3-70360DABD0C4}" EndProject @@ -26,6 +26,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency.EntityFrame EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency.EntityFrameworkCore.Test", "test\Cap.Consistency.EntityFrameworkCore.Test\Cap.Consistency.EntityFrameworkCore.Test.csproj", "{7442C942-1DDC-40E4-8F1B-654E721EAA45}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{3A6B6931-A123-477A-9469-8B468B5385AF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Kafka", "samples\Sample.Kafka\Sample.Kafka.csproj", "{2F095ED9-5BC9-4512-9013-A47685FB2508}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,6 +56,10 @@ Global {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Debug|Any CPU.Build.0 = Debug|Any CPU {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Release|Any CPU.ActiveCfg = Release|Any CPU {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Release|Any CPU.Build.0 = Release|Any CPU + {2F095ED9-5BC9-4512-9013-A47685FB2508}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F095ED9-5BC9-4512-9013-A47685FB2508}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F095ED9-5BC9-4512-9013-A47685FB2508}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F095ED9-5BC9-4512-9013-A47685FB2508}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -63,5 +71,6 @@ Global {55CF2C48-D390-40CF-8AD9-FA39F90E9217} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} {96111249-C4C3-4DC9-A887-32D583723AB1} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} {7442C942-1DDC-40E4-8F1B-654E721EAA45} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0} + {2F095ED9-5BC9-4512-9013-A47685FB2508} = {3A6B6931-A123-477A-9469-8B468B5385AF} EndGlobalSection EndGlobal diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj b/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj index 6352b19..408bff1 100644 --- a/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj +++ b/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj @@ -40,4 +40,8 @@ + + + + diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs b/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs index 0a5f82a..f662988 100644 --- a/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs +++ b/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Cap.Consistency.Infrastructure; using Microsoft.AspNetCore.Builder.Internal; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.EntityFrameworkCore; diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs b/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs index ad666cb..607ad8c 100644 --- a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs +++ b/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Cap.Consistency.Infrastructure; using Cap.Consistency.Test; using Microsoft.AspNetCore.Testing; using Microsoft.AspNetCore.Testing.xunit; diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs b/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs index 7b29384..3179ab3 100644 --- a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs +++ b/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs @@ -1,4 +1,5 @@ using System; +using Cap.Consistency.Infrastructure; using Cap.Consistency.Test; using Microsoft.AspNetCore.Testing; using Microsoft.EntityFrameworkCore; diff --git a/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj b/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj index 1ad1b6c..9f7439a 100644 --- a/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj +++ b/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj @@ -28,4 +28,8 @@ + + + + diff --git a/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs b/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs index 0abf94e..fe4ebd7 100644 --- a/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs +++ b/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using Cap.Consistency.Infrastructure; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -52,7 +53,7 @@ namespace Cap.Consistency.Test [Fact] public async Task CreateCallsStore() { var store = new Mock>(); - var message = new TestConsistencyMessage { Time = DateTime.Now }; + var message = new TestConsistencyMessage { SendTime = DateTime.Now }; store.Setup(x => x.CreateAsync(message, CancellationToken.None)).ReturnsAsync(OperateResult.Success).Verifiable(); var messageManager = TestConsistencyMessageManager(store.Object); @@ -63,7 +64,7 @@ namespace Cap.Consistency.Test } public ConsistencyMessageManager TestConsistencyMessageManager(IConsistencyMessageStore store = null) - where TMessage : class { + where TMessage : ConsistencyMessage { store = store ?? new Mock>().Object; var mockLogger = new Mock>>().Object; var manager = new ConsistencyMessageManager(store, null, mockLogger); diff --git a/test/Shared/MessageManagerTestBase.cs b/test/Shared/MessageManagerTestBase.cs index 2ece542..86d8372 100644 --- a/test/Shared/MessageManagerTestBase.cs +++ b/test/Shared/MessageManagerTestBase.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Linq.Expressions; using System.Security.Claims; using System.Threading.Tasks; +using Cap.Consistency.Infrastructure; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -13,12 +14,12 @@ using Xunit; namespace Cap.Consistency.Test { public abstract class MessageManagerTestBase : MessageManagerTestBase - where TMessage : class + where TMessage : ConsistencyMessage { } public abstract class MessageManagerTestBase - where TMessage : class + where TMessage : ConsistencyMessage where TKey : IEquatable { private const string NullValue = "(null)"; diff --git a/test/Shared/TestConsistencyMessage.cs b/test/Shared/TestConsistencyMessage.cs index 0539d8a..874a447 100644 --- a/test/Shared/TestConsistencyMessage.cs +++ b/test/Shared/TestConsistencyMessage.cs @@ -1,23 +1,11 @@ using System; +using Cap.Consistency.Infrastructure; namespace Cap.Consistency.Test { - - public class TestConsistencyMessage : TestConsistencyMessage - { - public TestConsistencyMessage() { - Id = Guid.NewGuid().ToString(); - } - } - - public class TestConsistencyMessage where TKey : IEquatable + public class TestConsistencyMessage : ConsistencyMessage { - public TestConsistencyMessage() { } - - public virtual TKey Id { get; set; } - - public virtual DateTime Time { get; set; } + } - }