Browse Source

refactor

master
yangxiaodong 7 years ago
parent
commit
ce7d76e4f0
9 changed files with 30 additions and 20 deletions
  1. +10
    -1
      Cap.sln
  2. +4
    -0
      test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj
  3. +1
    -0
      test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs
  4. +1
    -0
      test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs
  5. +1
    -0
      test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
  6. +4
    -0
      test/Cap.Consistency.Test/Cap.Consistency.Test.csproj
  7. +3
    -2
      test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs
  8. +3
    -2
      test/Shared/MessageManagerTestBase.cs
  9. +3
    -15
      test/Shared/TestConsistencyMessage.cs

+ 10
- 1
Cap.sln View File

@@ -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

+ 4
- 0
test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj View File

@@ -40,4 +40,8 @@
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="1.2.0-preview1-22815" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>

+ 1
- 0
test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs View File

@@ -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;


+ 1
- 0
test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs View File

@@ -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;


+ 1
- 0
test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs View File

@@ -1,4 +1,5 @@
using System;
using Cap.Consistency.Infrastructure;
using Cap.Consistency.Test;
using Microsoft.AspNetCore.Testing;
using Microsoft.EntityFrameworkCore;


+ 4
- 0
test/Cap.Consistency.Test/Cap.Consistency.Test.csproj View File

@@ -28,4 +28,8 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>

+ 3
- 2
test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs View File

@@ -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<IConsistencyMessageStore<TestConsistencyMessage>>();
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<TMessage> TestConsistencyMessageManager<TMessage>(IConsistencyMessageStore<TMessage> store = null)
where TMessage : class {
where TMessage : ConsistencyMessage {
store = store ?? new Mock<IConsistencyMessageStore<TMessage>>().Object;
var mockLogger = new Mock<ILogger<ConsistencyMessageManager<TMessage>>>().Object;
var manager = new ConsistencyMessageManager<TMessage>(store, null, mockLogger);


+ 3
- 2
test/Shared/MessageManagerTestBase.cs View File

@@ -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<TMessage> : MessageManagerTestBase<TMessage, string>
where TMessage : class
where TMessage : ConsistencyMessage
{
}

public abstract class MessageManagerTestBase<TMessage, TKey>
where TMessage : class
where TMessage : ConsistencyMessage
where TKey : IEquatable<TKey>
{
private const string NullValue = "(null)";


+ 3
- 15
test/Shared/TestConsistencyMessage.cs View File

@@ -1,23 +1,11 @@
using System;
using Cap.Consistency.Infrastructure;

namespace Cap.Consistency.Test
{
public class TestConsistencyMessage : TestConsistencyMessage<string>
{
public TestConsistencyMessage() {
Id = Guid.NewGuid().ToString();
}
}


public class TestConsistencyMessage<TKey> where TKey : IEquatable<TKey>
public class TestConsistencyMessage : ConsistencyMessage
{
public TestConsistencyMessage() { }

public virtual TKey Id { get; set; }

public virtual DateTime Time { get; set; }
}

}

Loading…
Cancel
Save