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
5591c9ac
Commit
5591c9ac
authored
May 24, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit tests for ConsumerServiceSelector
parent
0a428969
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
1 deletion
+76
-1
ConsumerServiceSelectorTest.cs
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs
+76
-1
No files found.
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs
View file @
5591c9ac
...
@@ -28,7 +28,7 @@ namespace DotNetCore.CAP.Test
...
@@ -28,7 +28,7 @@ namespace DotNetCore.CAP.Test
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
candidates
=
selector
.
SelectCandidates
();
var
candidates
=
selector
.
SelectCandidates
();
Assert
.
Equal
(
2
,
candidates
.
Count
);
Assert
.
Equal
(
6
,
candidates
.
Count
);
}
}
[
Fact
]
[
Fact
]
...
@@ -42,6 +42,66 @@ namespace DotNetCore.CAP.Test
...
@@ -42,6 +42,66 @@ namespace DotNetCore.CAP.Test
Assert
.
NotNull
(
bestCandidates
.
MethodInfo
);
Assert
.
NotNull
(
bestCandidates
.
MethodInfo
);
Assert
.
Equal
(
typeof
(
Task
),
bestCandidates
.
MethodInfo
.
ReturnType
);
Assert
.
Equal
(
typeof
(
Task
),
bestCandidates
.
MethodInfo
.
ReturnType
);
}
}
[
Theory
]
[
InlineData
(
"Candidates.Asterisk"
)]
[
InlineData
(
"candidates.Asterisk"
)]
[
InlineData
(
"AAA.BBB.Asterisk"
)]
[
InlineData
(
"aaa.bbb.Asterisk"
)]
public
void
CanFindAsteriskTopic
(
string
topic
)
{
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
candidates
=
selector
.
SelectCandidates
();
var
bestCandidates
=
selector
.
SelectBestCandidate
(
topic
,
candidates
);
Assert
.
NotNull
(
bestCandidates
);
}
[
Theory
]
[
InlineData
(
"Candidates.Asterisk.AAA"
)]
[
InlineData
(
"AAA.BBB.CCC.Asterisk"
)]
[
InlineData
(
"aaa.BBB.ccc.Asterisk"
)]
[
InlineData
(
"Asterisk.aaa.bbb"
)]
public
void
CanNotFindAsteriskTopic
(
string
topic
)
{
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
candidates
=
selector
.
SelectCandidates
();
var
bestCandidates
=
selector
.
SelectBestCandidate
(
topic
,
candidates
);
Assert
.
Null
(
bestCandidates
);
}
[
Theory
]
[
InlineData
(
"Candidates.Pound.AAA"
)]
[
InlineData
(
"Candidates.Pound.AAA.BBB"
)]
[
InlineData
(
"AAA.Pound"
)]
[
InlineData
(
"aaa.Pound"
)]
[
InlineData
(
"aaa.bbb.Pound"
)]
[
InlineData
(
"aaa.BBB.Pound"
)]
public
void
CanFindPoundTopic
(
string
topic
)
{
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
candidates
=
selector
.
SelectCandidates
();
var
bestCandidates
=
selector
.
SelectBestCandidate
(
topic
,
candidates
);
Assert
.
NotNull
(
bestCandidates
);
}
[
Theory
]
[
InlineData
(
"Pound"
)]
[
InlineData
(
"aaa.Pound.AAA.BBB"
)]
[
InlineData
(
"Pound.AAA"
)]
[
InlineData
(
"Pound.aaa"
)]
[
InlineData
(
"AAA.Pound.aaa"
)]
public
void
CanNotFindPoundTopic
(
string
topic
)
{
var
selector
=
_provider
.
GetRequiredService
<
IConsumerServiceSelector
>();
var
candidates
=
selector
.
SelectCandidates
();
var
bestCandidates
=
selector
.
SelectBestCandidate
(
topic
,
candidates
);
Assert
.
Null
(
bestCandidates
);
}
}
}
public
class
CandidatesTopic
:
TopicAttribute
public
class
CandidatesTopic
:
TopicAttribute
...
@@ -73,6 +133,21 @@ namespace DotNetCore.CAP.Test
...
@@ -73,6 +133,21 @@ namespace DotNetCore.CAP.Test
{
{
Console
.
WriteLine
(
"GetFoo2() method has bee excuted."
);
Console
.
WriteLine
(
"GetFoo2() method has bee excuted."
);
}
}
[
CandidatesTopic
(
"*.*.Asterisk"
)]
[
CandidatesTopic
(
"*.Asterisk"
)]
public
void
GetFooAsterisk
()
{
Console
.
WriteLine
(
"GetFoo2Asterisk() method has bee excuted."
);
}
[
CandidatesTopic
(
"Candidates.Pound.#"
)]
[
CandidatesTopic
(
"#.Pound"
)]
public
void
GetFooPound
()
{
Console
.
WriteLine
(
"GetFoo2Pound() method has bee excuted."
);
}
}
}
public
class
CandidatesBarTest
:
IBarTest
public
class
CandidatesBarTest
:
IBarTest
...
...
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