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
af4b8e1a
Commit
af4b8e1a
authored
Jul 18, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test.
parent
223430ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
0 deletions
+107
-0
QueueExecutorFactoryTest.cs
test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs
+48
-0
SubscribeFinderTest.cs
test/DotNetCore.CAP.Test/SubscribeFinderTest.cs
+59
-0
No files found.
test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs
0 → 100644
View file @
af4b8e1a
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Microsoft.Extensions.DependencyInjection
;
using
Xunit
;
namespace
DotNetCore.CAP.Test
{
public
class
QueueExecutorFactoryTest
{
private
IServiceProvider
_provider
;
public
QueueExecutorFactoryTest
()
{
var
services
=
new
ServiceCollection
();
services
.
AddLogging
();
services
.
AddOptions
();
services
.
AddCap
(
x
=>
{
});
_provider
=
services
.
BuildServiceProvider
();
}
[
Fact
]
public
void
CanCreateInstance
()
{
var
queueExecutorFactory
=
_provider
.
GetService
<
IQueueExecutorFactory
>();
Assert
.
NotNull
(
queueExecutorFactory
);
var
publishExecutor
=
queueExecutorFactory
.
GetInstance
(
Models
.
MessageType
.
Publish
);
Assert
.
Null
(
publishExecutor
);
var
disPatchExector
=
queueExecutorFactory
.
GetInstance
(
Models
.
MessageType
.
Subscribe
);
Assert
.
NotNull
(
disPatchExector
);
}
[
Fact
]
public
void
CanGetSubscribeExector
()
{
var
queueExecutorFactory
=
_provider
.
GetService
<
IQueueExecutorFactory
>();
Assert
.
NotNull
(
queueExecutorFactory
);
var
publishExecutor
=
queueExecutorFactory
.
GetInstance
(
Models
.
MessageType
.
Publish
);
Assert
.
Equal
(
null
,
publishExecutor
);
}
}
}
test/DotNetCore.CAP.Test/SubscribeFinderTest.cs
0 → 100644
View file @
af4b8e1a
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
DotNetCore.CAP.Abstractions
;
using
Microsoft.Extensions.DependencyInjection
;
using
Xunit
;
namespace
DotNetCore.CAP.Test
{
public
class
SubscribeFinderTest
{
private
IServiceProvider
_provider
;
public
SubscribeFinderTest
()
{
var
services
=
new
ServiceCollection
();
services
.
AddScoped
<
ITestService
,
TestService
>();
services
.
AddCap
(
x
=>
{
});
_provider
=
services
.
BuildServiceProvider
();
}
[
Fact
]
public
void
CanFindControllers
()
{
}
[
Fact
]
public
void
CanFindSubscribeService
()
{
var
testService
=
_provider
.
GetService
<
ICapSubscribe
>();
Assert
.
NotNull
(
testService
);
Assert
.
IsType
<
TestService
>(
testService
);
}
}
public
class
HomeController
{
}
public
interface
ITestService
{
}
public
class
TestService
:
ITestService
,
ICapSubscribe
{
[
CapSubscribe
(
"test"
)]
public
void
Index
()
{
}
}
public
class
CapSubscribeAttribute
:
TopicAttribute
{
public
CapSubscribeAttribute
(
string
name
)
:
base
(
name
)
{
}
}
}
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