Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
013c6169
Commit
013c6169
authored
Jun 23, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests of CAP builder.
parent
d4074414
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
158 additions
and
167 deletions
+158
-167
DotNetCore.CAP.EntityFrameworkCore.Test.csproj
...kCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
+1
-1
CAP.BuilderTest.cs
test/DotNetCore.CAP.Test/CAP.BuilderTest.cs
+101
-0
ConsistencyBuilderTest.cs
test/DotNetCore.CAP.Test/ConsistencyBuilderTest.cs
+0
-52
ConsistencyMessageManagerTest.cs
test/DotNetCore.CAP.Test/ConsistencyMessageManagerTest.cs
+0
-74
ConsistencyOptionsTest.cs
test/DotNetCore.CAP.Test/ConsistencyOptionsTest.cs
+1
-0
DotNetCore.CAP.Test.csproj
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
+5
-1
NoopMessageStore.cs
test/DotNetCore.CAP.Test/NoopMessageStore.cs
+50
-39
No files found.
test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
View file @
013c6169
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Moq" Version="4.7.
10
" />
<PackageReference Include="Moq" Version="4.7.
63
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
...
...
test/DotNetCore.CAP.Test/CAP.BuilderTest.cs
0 → 100644
View file @
013c6169
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Infrastructure
;
using
DotNetCore.CAP.Job
;
using
Microsoft.Extensions.DependencyInjection
;
using
Xunit
;
namespace
DotNetCore.CAP.Test
{
public
class
CapBuilderTest
{
[
Fact
]
public
void
CanOverrideMessageStore
()
{
var
services
=
new
ServiceCollection
();
services
.
AddConsistency
().
AddMessageStore
<
MyMessageStore
>();
var
thingy
=
services
.
BuildServiceProvider
()
.
GetRequiredService
<
ICapMessageStore
>()
as
MyMessageStore
;
Assert
.
NotNull
(
thingy
);
}
[
Fact
]
public
void
CanOverrideJobs
()
{
var
services
=
new
ServiceCollection
();
services
.
AddConsistency
().
AddJobs
<
MyJobTest
>();
var
thingy
=
services
.
BuildServiceProvider
()
.
GetRequiredService
<
IJob
>()
as
MyJobTest
;
Assert
.
NotNull
(
thingy
);
}
[
Fact
]
public
void
CanOverrideProducerService
()
{
var
services
=
new
ServiceCollection
();
services
.
AddConsistency
().
AddProducerService
<
MyProducerService
>();
var
thingy
=
services
.
BuildServiceProvider
()
.
GetRequiredService
<
ICapProducerService
>()
as
MyProducerService
;
Assert
.
NotNull
(
thingy
);
}
private
class
MyProducerService
:
ICapProducerService
{
public
Task
SendAsync
(
string
topic
,
string
content
)
{
throw
new
NotImplementedException
();
}
}
private
class
MyJobTest
:
IJob
{
public
Task
ExecuteAsync
()
{
throw
new
NotImplementedException
();
}
}
private
class
MyMessageStore
:
ICapMessageStore
{
public
Task
<
OperateResult
>
CreateAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
OperateResult
>
DeleteAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
ConsistencyMessage
>
FindByIdAsync
(
string
messageId
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
string
>
GeConsistencyMessageIdAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
ConsistencyMessage
>
GetFirstEnqueuedMessageAsync
(
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
OperateResult
>
UpdateAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
}
}
}
\ No newline at end of file
test/DotNetCore.CAP.Test/ConsistencyBuilderTest.cs
deleted
100644 → 0
View file @
d4074414
//using System;
//using System.Threading;
//using System.Threading.Tasks;
//using DotNetCore.CAP.Infrastructure;
//using DotNetCore.CAP.Store;
//using Microsoft.Extensions.DependencyInjection;
//using Xunit;
//namespace DotNetCore.CAP.Test
//{
// public class ConsistencyBuilderTest
// {
// [Fact]
// public void CanOverrideMessageStore() {
// var services = new ServiceCollection();
// services.AddConsistency().AddMessageStore<MyUberThingy>();
// var thingy = services.BuildServiceProvider().GetRequiredService<IConsistencyMessageStore>() as MyUberThingy;
// Assert.NotNull(thingy);
// }
// private class MyUberThingy : IConsistencyMessageStore
// {
// public Task<OperateResult> CreateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// public Task<OperateResult> DeleteAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// public void Dispose() {
// throw new NotImplementedException();
// }
// public Task<ConsistencyMessage> FindByIdAsync(string messageId, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// public Task<string> GeConsistencyMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// public Task<string> GetMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// public Task<OperateResult> UpdateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
// throw new NotImplementedException();
// }
// }
// }
//}
\ No newline at end of file
test/DotNetCore.CAP.Test/ConsistencyMessageManagerTest.cs
deleted
100644 → 0
View file @
d4074414
//using System;
//using System.Threading;
//using System.Threading.Tasks;
//using DotNetCore.CAP.Infrastructure;
//using DotNetCore.CAP.Store;
//using Microsoft.AspNetCore.Http;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Logging;
//using Moq;
//using Xunit;
//namespace DotNetCore.CAP.Test
//{
// public class ConsistencyMessageManagerTest
// {
// [Fact]
// public void EnsureDefaultServicesDefaultsWithStoreWorks() {
// var services = new ServiceCollection()
// .AddTransient<IConsistencyMessageStore, NoopMessageStore>();
// services.AddConsistency();
// services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// services.AddLogging();
// var manager = services.BuildServiceProvider()
// .GetRequiredService<IConsistencyMessageStore >();
// Assert.NotNull(manager);
// }
// [Fact]
// public void AddMessageManagerWithCustomerMannagerReturnsSameInstance() {
// var services = new ServiceCollection()
// .AddTransient<IConsistencyMessageStore, NoopMessageStore>()
// .AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// services.AddLogging();
// //services.AddConsistency()
// // .AddConsistencyMessageManager<CustomMessageManager>();
// var provider = services.BuildServiceProvider();
// Assert.Same(provider.GetRequiredService<IConsistencyMessageStore >(),
// provider.GetRequiredService<CustomMessageManager>());
// }
// public class CustomMessageManager : IConsistencyMessageStore
// {
// public CustomMessageManager()
// : base(new Mock<IConsistencyMessageStore>().Object, null, null) {
// }
// }
// [Fact]
// public async Task CreateCallsStore() {
// var store = new Mock<IConsistencyMessageStore>();
// var message = new ConsistencyMessage { SendTime = DateTime.Now };
// store.Setup(x => x.CreateAsync(message, CancellationToken.None)).ReturnsAsync(OperateResult.Success).Verifiable();
// var messageManager = TestConsistencyMessageManager(store.Object);
// var result = await messageManager.CreateAsync(message);
// Assert.True(result.Succeeded);
// store.VerifyAll();
// }
// public IConsistencyMessageStore TestConsistencyMessageManager(IConsistencyMessageStore store = null) {
// store = store ?? new Mock<IConsistencyMessageStore>().Object;
// var mockLogger = new Mock<ILogger<IConsistencyMessageStore >>().Object;
// var manager = new IConsistencyMessageStore (store, null, mockLogger);
// return manager;
// }
// }
//}
\ No newline at end of file
test/DotNetCore.CAP.Test/ConsistencyOptionsTest.cs
View file @
013c6169
...
@@ -2,5 +2,6 @@
...
@@ -2,5 +2,6 @@
{
{
public
class
ConsistencyOptionsTest
public
class
ConsistencyOptionsTest
{
{
}
}
}
}
\ No newline at end of file
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
View file @
013c6169
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Moq" Version="4.7.
10
" />
<PackageReference Include="Moq" Version="4.7.
63
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
</ItemGroup>
</ItemGroup>
...
@@ -32,4 +32,8 @@
...
@@ -32,4 +32,8 @@
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<Folder Include="Job\" />
</ItemGroup>
</Project>
</Project>
test/DotNetCore.CAP.Test/NoopMessageStore.cs
View file @
013c6169
//using System;
using
System
;
//using System.Threading;
using
System.Threading
;
//using System.Threading.Tasks;
using
System.Threading.Tasks
;
//using DotNetCore.CAP.Infrastructure;
using
DotNetCore.CAP.Infrastructure
;
//using DotNetCore.CAP.Store;
namespace
DotNetCore.CAP.Test
//namespace DotNetCore.CAP.Test
{
//{
public
class
NoopMessageStore
:
ICapMessageStore
// public class NoopMessageStore : IConsistencyMessageStore
{
// {
public
Task
<
OperateResult
>
CreateAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
// public Task<OperateResult> CreateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
{
// throw new NotImplementedException();
throw
new
NotImplementedException
();
// }
}
// public Task<OperateResult> DeleteAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
public
Task
<
OperateResult
>
DeleteAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
// throw new NotImplementedException();
{
// }
throw
new
NotImplementedException
();
}
// public void Dispose() {
// throw new NotImplementedException();
public
void
Dispose
()
// }
{
throw
new
NotImplementedException
();
// public Task<ConsistencyMessage> FindByIdAsync(string messageId, CancellationToken cancellationToken) {
}
// throw new NotImplementedException();
// }
public
Task
<
ConsistencyMessage
>
FindByIdAsync
(
string
messageId
,
CancellationToken
cancellationToken
)
{
// public Task<string> GeConsistencyMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
throw
new
NotImplementedException
();
// throw new NotImplementedException();
}
// }
public
Task
<
string
>
GeConsistencyMessageIdAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
// public Task<string> GetMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
{
// throw new NotImplementedException();
throw
new
NotImplementedException
();
// }
}
// public Task<OperateResult> UpdateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
public
Task
<
ConsistencyMessage
>
GetFirstEnqueuedMessageAsync
(
CancellationToken
cancellationToken
)
// throw new NotImplementedException();
{
// }
throw
new
NotImplementedException
();
// }
}
//}
\ No newline at end of file
public
Task
<
string
>
GetMessageIdAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
public
Task
<
OperateResult
>
UpdateAsync
(
ConsistencyMessage
message
,
CancellationToken
cancellationToken
)
{
throw
new
NotImplementedException
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment