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
816fb33c
Commit
816fb33c
authored
Aug 13, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade to .net standard 2.0.
parent
5beb347b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
611 additions
and
115 deletions
+611
-115
.gitignore
.gitignore
+2
-1
DotNetCore.CAP.Kafka.csproj
src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj
+6
-1
DotNetCore.CAP.MySql.csproj
src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj
+4
-8
DotNetCore.CAP.PostgreSql.csproj
...otNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj
+3
-7
DotNetCore.CAP.RabbitMQ.csproj
src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj
+1
-1
DotNetCore.CAP.SqlServer.csproj
src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj
+3
-7
DotNetCore.CAP.csproj
src/DotNetCore.CAP/DotNetCore.CAP.csproj
+7
-14
ObjectId.cs
src/DotNetCore.CAP/Infrastructure/ObjectId.cs
+539
-0
DotNetCore.CAP.MySql.Test.csproj
...otNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj
+14
-19
DotNetCore.CAP.SqlServer.Test.csproj
...e.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj
+16
-21
AssemblyInfo.cs
.../DotNetCore.CAP.SqlServer.Test/Properties/AssemblyInfo.cs
+0
-18
SqlServerStorageTest.cs
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs
+4
-4
ConsumerServiceSelectorTest.cs
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs
+1
-1
DotNetCore.CAP.Test.csproj
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
+8
-10
StateChangerTest.cs
test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs
+2
-2
QueueExecutorFactoryTest.cs
test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs
+1
-1
No files found.
.gitignore
View file @
816fb33c
...
@@ -33,4 +33,5 @@ bin/
...
@@ -33,4 +33,5 @@ bin/
/.idea/.idea.CAP
/.idea/.idea.CAP
/.idea/.idea.CAP
/.idea/.idea.CAP
/.idea
/.idea
Properties
Properties
\ No newline at end of file
/pack.bat
src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj
View file @
816fb33c
...
@@ -3,10 +3,15 @@
...
@@ -3,10 +3,15 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6
;</TargetFrameworks>
<TargetFrameworks>netstandard
2.0
;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP.Kafka</AssemblyName>
<AssemblyName>DotNetCore.CAP.Kafka</AssemblyName>
<PackageTags>$(PackageTags);Kafka</PackageTags>
<PackageTags>$(PackageTags);Kafka</PackageTags>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<Content Remove="C:\Users\yangxiaodong\.nuget\packages\librdkafka.redist\0.11.0\build\net\..\..\runtimes\win7-x64\native\**" />
<Content Remove="C:\Users\yangxiaodong\.nuget\packages\librdkafka.redist\0.11.0\build\net\..\..\runtimes\win7-x86\native\**" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="0.11.0" />
<PackageReference Include="Confluent.Kafka" Version="0.11.0" />
...
...
src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj
View file @
816fb33c
...
@@ -3,20 +3,16 @@
...
@@ -3,20 +3,16 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6;netstandard
2.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP.MySql</AssemblyName>
<AssemblyName>DotNetCore.CAP.MySql</AssemblyName>
<PackageTags>$(PackageTags);MySQL</PackageTags>
<PackageTags>$(PackageTags);MySQL</PackageTags>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.6|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
2.0.0
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
2.0.0
" />
<PackageReference Include="MySqlConnector" Version="0.24.
0
" />
<PackageReference Include="MySqlConnector" Version="0.24.
2
" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj
View file @
816fb33c
...
@@ -3,19 +3,15 @@
...
@@ -3,19 +3,15 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6;netstandard
2.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP.PostgreSql</AssemblyName>
<AssemblyName>DotNetCore.CAP.PostgreSql</AssemblyName>
<PackageTags>$(PackageTags);PostgreSQL</PackageTags>
<PackageTags>$(PackageTags);PostgreSQL</PackageTags>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.6|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
2.0.0
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
2.0.0
" />
<PackageReference Include="Npgsql" Version="3.2.5" />
<PackageReference Include="Npgsql" Version="3.2.5" />
</ItemGroup>
</ItemGroup>
...
...
src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj
View file @
816fb33c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6
;</TargetFrameworks>
<TargetFrameworks>netstandard
2.0
;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP.RabbitMQ</AssemblyName>
<AssemblyName>DotNetCore.CAP.RabbitMQ</AssemblyName>
<PackageTags>$(PackageTags);RabbitMQ</PackageTags>
<PackageTags>$(PackageTags);RabbitMQ</PackageTags>
</PropertyGroup>
</PropertyGroup>
...
...
src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj
View file @
816fb33c
...
@@ -3,19 +3,15 @@
...
@@ -3,19 +3,15 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6;netstandard
2.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP.SqlServer</AssemblyName>
<AssemblyName>DotNetCore.CAP.SqlServer</AssemblyName>
<PackageTags>$(PackageTags);SQL Server</PackageTags>
<PackageTags>$(PackageTags);SQL Server</PackageTags>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.6|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
2.0.0
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="
2.0.0
" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
src/DotNetCore.CAP/DotNetCore.CAP.csproj
View file @
816fb33c
...
@@ -3,28 +3,21 @@
...
@@ -3,28 +3,21 @@
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard
1.6;netstandard
2.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>DotNetCore.CAP</AssemblyName>
<AssemblyName>DotNetCore.CAP</AssemblyName>
<PackageTags>$(PackageTags);</PackageTags>
<PackageTags>$(PackageTags);</PackageTags>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Options" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Options" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="
2.0.0
" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0-*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0-*" />
</ItemGroup>
</Project>
</Project>
src/DotNetCore.CAP/Infrastructure/ObjectId.cs
0 → 100644
View file @
816fb33c
using
System
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading
;
namespace
DotNetCore.CAP
{
/// <summary>Represents an ObjectId
/// </summary>
[
Serializable
]
public
struct
ObjectId
:
IComparable
<
ObjectId
>,
IEquatable
<
ObjectId
>
{
// private static fields
private
static
readonly
DateTime
__unixEpoch
;
private
static
readonly
long
__dateTimeMaxValueMillisecondsSinceEpoch
;
private
static
readonly
long
__dateTimeMinValueMillisecondsSinceEpoch
;
private
static
ObjectId
__emptyInstance
=
default
(
ObjectId
);
private
static
int
__staticMachine
;
private
static
short
__staticPid
;
private
static
int
__staticIncrement
;
// high byte will be masked out when generating new ObjectId
private
static
uint
[]
_lookup32
=
Enumerable
.
Range
(
0
,
256
).
Select
(
i
=>
{
string
s
=
i
.
ToString
(
"x2"
);
return
((
uint
)
s
[
0
])
+
((
uint
)
s
[
1
]
<<
16
);
}).
ToArray
();
// we're using 14 bytes instead of 12 to hold the ObjectId in memory but unlike a byte[] there is no additional object on the heap
// the extra two bytes are not visible to anyone outside of this class and they buy us considerable simplification
// an additional advantage of this representation is that it will serialize to JSON without any 64 bit overflow problems
private
int
_timestamp
;
private
int
_machine
;
private
short
_pid
;
private
int
_increment
;
// static constructor
static
ObjectId
()
{
__unixEpoch
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
);
__dateTimeMaxValueMillisecondsSinceEpoch
=
(
DateTime
.
MaxValue
-
__unixEpoch
).
Ticks
/
10000
;
__dateTimeMinValueMillisecondsSinceEpoch
=
(
DateTime
.
MinValue
-
__unixEpoch
).
Ticks
/
10000
;
__staticMachine
=
GetMachineHash
();
__staticIncrement
=
(
new
Random
()).
Next
();
__staticPid
=
(
short
)
GetCurrentProcessId
();
}
// constructors
/// <summary>
/// Initializes a new instance of the ObjectId class.
/// </summary>
/// <param name="bytes">The bytes.</param>
public
ObjectId
(
byte
[]
bytes
)
{
if
(
bytes
==
null
)
{
throw
new
ArgumentNullException
(
"bytes"
);
}
Unpack
(
bytes
,
out
_timestamp
,
out
_machine
,
out
_pid
,
out
_increment
);
}
/// <summary>
/// Initializes a new instance of the ObjectId class.
/// </summary>
/// <param name="timestamp">The timestamp (expressed as a DateTime).</param>
/// <param name="machine">The machine hash.</param>
/// <param name="pid">The PID.</param>
/// <param name="increment">The increment.</param>
public
ObjectId
(
DateTime
timestamp
,
int
machine
,
short
pid
,
int
increment
)
:
this
(
GetTimestampFromDateTime
(
timestamp
),
machine
,
pid
,
increment
)
{
}
/// <summary>
/// Initializes a new instance of the ObjectId class.
/// </summary>
/// <param name="timestamp">The timestamp.</param>
/// <param name="machine">The machine hash.</param>
/// <param name="pid">The PID.</param>
/// <param name="increment">The increment.</param>
public
ObjectId
(
int
timestamp
,
int
machine
,
short
pid
,
int
increment
)
{
if
((
machine
&
0xff000000
)
!=
0
)
{
throw
new
ArgumentOutOfRangeException
(
"machine"
,
"The machine value must be between 0 and 16777215 (it must fit in 3 bytes)."
);
}
if
((
increment
&
0xff000000
)
!=
0
)
{
throw
new
ArgumentOutOfRangeException
(
"increment"
,
"The increment value must be between 0 and 16777215 (it must fit in 3 bytes)."
);
}
_timestamp
=
timestamp
;
_machine
=
machine
;
_pid
=
pid
;
_increment
=
increment
;
}
/// <summary>
/// Initializes a new instance of the ObjectId class.
/// </summary>
/// <param name="value">The value.</param>
public
ObjectId
(
string
value
)
{
if
(
value
==
null
)
{
throw
new
ArgumentNullException
(
"value"
);
}
Unpack
(
ParseHexString
(
value
),
out
_timestamp
,
out
_machine
,
out
_pid
,
out
_increment
);
}
// public static properties
/// <summary>
/// Gets an instance of ObjectId where the value is empty.
/// </summary>
public
static
ObjectId
Empty
{
get
{
return
__emptyInstance
;
}
}
// public properties
/// <summary>
/// Gets the timestamp.
/// </summary>
public
int
Timestamp
{
get
{
return
_timestamp
;
}
}
/// <summary>
/// Gets the machine.
/// </summary>
public
int
Machine
{
get
{
return
_machine
;
}
}
/// <summary>
/// Gets the PID.
/// </summary>
public
short
Pid
{
get
{
return
_pid
;
}
}
/// <summary>
/// Gets the increment.
/// </summary>
public
int
Increment
{
get
{
return
_increment
;
}
}
/// <summary>
/// Gets the creation time (derived from the timestamp).
/// </summary>
public
DateTime
CreationTime
{
get
{
return
__unixEpoch
.
AddSeconds
(
_timestamp
);
}
}
// public operators
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId</param>
/// <returns>True if the first ObjectId is less than the second ObjectId.</returns>
public
static
bool
operator
<(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
lhs
.
CompareTo
(
rhs
)
<
0
;
}
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId</param>
/// <returns>True if the first ObjectId is less than or equal to the second ObjectId.</returns>
public
static
bool
operator
<=(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
lhs
.
CompareTo
(
rhs
)
<=
0
;
}
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId.</param>
/// <returns>True if the two ObjectIds are equal.</returns>
public
static
bool
operator
==(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
lhs
.
Equals
(
rhs
);
}
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId.</param>
/// <returns>True if the two ObjectIds are not equal.</returns>
public
static
bool
operator
!=(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
!(
lhs
==
rhs
);
}
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId</param>
/// <returns>True if the first ObjectId is greather than or equal to the second ObjectId.</returns>
public
static
bool
operator
>=(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
lhs
.
CompareTo
(
rhs
)
>=
0
;
}
/// <summary>
/// Compares two ObjectIds.
/// </summary>
/// <param name="lhs">The first ObjectId.</param>
/// <param name="rhs">The other ObjectId</param>
/// <returns>True if the first ObjectId is greather than the second ObjectId.</returns>
public
static
bool
operator
>(
ObjectId
lhs
,
ObjectId
rhs
)
{
return
lhs
.
CompareTo
(
rhs
)
>
0
;
}
// public static methods
/// <summary>
/// Generates a new ObjectId with a unique value.
/// </summary>
/// <returns>An ObjectId.</returns>
public
static
ObjectId
GenerateNewId
()
{
return
GenerateNewId
(
GetTimestampFromDateTime
(
DateTime
.
UtcNow
));
}
/// <summary>
/// Generates a new ObjectId with a unique value (with the timestamp component based on a given DateTime).
/// </summary>
/// <param name="timestamp">The timestamp component (expressed as a DateTime).</param>
/// <returns>An ObjectId.</returns>
public
static
ObjectId
GenerateNewId
(
DateTime
timestamp
)
{
return
GenerateNewId
(
GetTimestampFromDateTime
(
timestamp
));
}
/// <summary>
/// Generates a new ObjectId with a unique value (with the given timestamp).
/// </summary>
/// <param name="timestamp">The timestamp component.</param>
/// <returns>An ObjectId.</returns>
public
static
ObjectId
GenerateNewId
(
int
timestamp
)
{
int
increment
=
Interlocked
.
Increment
(
ref
__staticIncrement
)
&
0x00ffffff
;
// only use low order 3 bytes
return
new
ObjectId
(
timestamp
,
__staticMachine
,
__staticPid
,
increment
);
}
/// <summary>
/// Generates a new ObjectId string with a unique value.
/// </summary>
/// <returns>The string value of the new generated ObjectId.</returns>
public
static
string
GenerateNewStringId
()
{
return
GenerateNewId
().
ToString
();
}
/// <summary>
/// Packs the components of an ObjectId into a byte array.
/// </summary>
/// <param name="timestamp">The timestamp.</param>
/// <param name="machine">The machine hash.</param>
/// <param name="pid">The PID.</param>
/// <param name="increment">The increment.</param>
/// <returns>A byte array.</returns>
public
static
byte
[]
Pack
(
int
timestamp
,
int
machine
,
short
pid
,
int
increment
)
{
if
((
machine
&
0xff000000
)
!=
0
)
{
throw
new
ArgumentOutOfRangeException
(
"machine"
,
"The machine value must be between 0 and 16777215 (it must fit in 3 bytes)."
);
}
if
((
increment
&
0xff000000
)
!=
0
)
{
throw
new
ArgumentOutOfRangeException
(
"increment"
,
"The increment value must be between 0 and 16777215 (it must fit in 3 bytes)."
);
}
byte
[]
bytes
=
new
byte
[
12
];
bytes
[
0
]
=
(
byte
)(
timestamp
>>
24
);
bytes
[
1
]
=
(
byte
)(
timestamp
>>
16
);
bytes
[
2
]
=
(
byte
)(
timestamp
>>
8
);
bytes
[
3
]
=
(
byte
)(
timestamp
);
bytes
[
4
]
=
(
byte
)(
machine
>>
16
);
bytes
[
5
]
=
(
byte
)(
machine
>>
8
);
bytes
[
6
]
=
(
byte
)(
machine
);
bytes
[
7
]
=
(
byte
)(
pid
>>
8
);
bytes
[
8
]
=
(
byte
)(
pid
);
bytes
[
9
]
=
(
byte
)(
increment
>>
16
);
bytes
[
10
]
=
(
byte
)(
increment
>>
8
);
bytes
[
11
]
=
(
byte
)(
increment
);
return
bytes
;
}
/// <summary>
/// Parses a string and creates a new ObjectId.
/// </summary>
/// <param name="s">The string value.</param>
/// <returns>A ObjectId.</returns>
public
static
ObjectId
Parse
(
string
s
)
{
if
(
s
==
null
)
{
throw
new
ArgumentNullException
(
"s"
);
}
if
(
s
.
Length
!=
24
)
{
throw
new
ArgumentOutOfRangeException
(
"s"
,
"ObjectId string value must be 24 characters."
);
}
return
new
ObjectId
(
ParseHexString
(
s
));
}
/// <summary>
/// Unpacks a byte array into the components of an ObjectId.
/// </summary>
/// <param name="bytes">A byte array.</param>
/// <param name="timestamp">The timestamp.</param>
/// <param name="machine">The machine hash.</param>
/// <param name="pid">The PID.</param>
/// <param name="increment">The increment.</param>
public
static
void
Unpack
(
byte
[]
bytes
,
out
int
timestamp
,
out
int
machine
,
out
short
pid
,
out
int
increment
)
{
if
(
bytes
==
null
)
{
throw
new
ArgumentNullException
(
"bytes"
);
}
if
(
bytes
.
Length
!=
12
)
{
throw
new
ArgumentOutOfRangeException
(
"bytes"
,
"Byte array must be 12 bytes long."
);
}
timestamp
=
(
bytes
[
0
]
<<
24
)
+
(
bytes
[
1
]
<<
16
)
+
(
bytes
[
2
]
<<
8
)
+
bytes
[
3
];
machine
=
(
bytes
[
4
]
<<
16
)
+
(
bytes
[
5
]
<<
8
)
+
bytes
[
6
];
pid
=
(
short
)((
bytes
[
7
]
<<
8
)
+
bytes
[
8
]);
increment
=
(
bytes
[
9
]
<<
16
)
+
(
bytes
[
10
]
<<
8
)
+
bytes
[
11
];
}
// private static methods
/// <summary>
/// Gets the current process id. This method exists because of how CAS operates on the call stack, checking
/// for permissions before executing the method. Hence, if we inlined this call, the calling method would not execute
/// before throwing an exception requiring the try/catch at an even higher level that we don't necessarily control.
/// </summary>
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
private
static
int
GetCurrentProcessId
()
{
return
Process
.
GetCurrentProcess
().
Id
;
}
private
static
int
GetMachineHash
()
{
var
hostName
=
Environment
.
MachineName
;
// use instead of Dns.HostName so it will work offline
var
md5
=
MD5
.
Create
();
var
hash
=
md5
.
ComputeHash
(
Encoding
.
UTF8
.
GetBytes
(
hostName
));
return
(
hash
[
0
]
<<
16
)
+
(
hash
[
1
]
<<
8
)
+
hash
[
2
];
// use first 3 bytes of hash
}
private
static
int
GetTimestampFromDateTime
(
DateTime
timestamp
)
{
return
(
int
)
Math
.
Floor
((
ToUniversalTime
(
timestamp
)
-
__unixEpoch
).
TotalSeconds
);
}
// public methods
/// <summary>
/// Compares this ObjectId to another ObjectId.
/// </summary>
/// <param name="other">The other ObjectId.</param>
/// <returns>A 32-bit signed integer that indicates whether this ObjectId is less than, equal to, or greather than the other.</returns>
public
int
CompareTo
(
ObjectId
other
)
{
int
r
=
_timestamp
.
CompareTo
(
other
.
_timestamp
);
if
(
r
!=
0
)
{
return
r
;
}
r
=
_machine
.
CompareTo
(
other
.
_machine
);
if
(
r
!=
0
)
{
return
r
;
}
r
=
_pid
.
CompareTo
(
other
.
_pid
);
if
(
r
!=
0
)
{
return
r
;
}
return
_increment
.
CompareTo
(
other
.
_increment
);
}
/// <summary>
/// Compares this ObjectId to another ObjectId.
/// </summary>
/// <param name="rhs">The other ObjectId.</param>
/// <returns>True if the two ObjectIds are equal.</returns>
public
bool
Equals
(
ObjectId
rhs
)
{
return
_timestamp
==
rhs
.
_timestamp
&&
_machine
==
rhs
.
_machine
&&
_pid
==
rhs
.
_pid
&&
_increment
==
rhs
.
_increment
;
}
/// <summary>
/// Compares this ObjectId to another object.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns>True if the other object is an ObjectId and equal to this one.</returns>
public
override
bool
Equals
(
object
obj
)
{
if
(
obj
is
ObjectId
)
{
return
Equals
((
ObjectId
)
obj
);
}
else
{
return
false
;
}
}
/// <summary>
/// Gets the hash code.
/// </summary>
/// <returns>The hash code.</returns>
public
override
int
GetHashCode
()
{
int
hash
=
17
;
hash
=
37
*
hash
+
_timestamp
.
GetHashCode
();
hash
=
37
*
hash
+
_machine
.
GetHashCode
();
hash
=
37
*
hash
+
_pid
.
GetHashCode
();
hash
=
37
*
hash
+
_increment
.
GetHashCode
();
return
hash
;
}
/// <summary>
/// Converts the ObjectId to a byte array.
/// </summary>
/// <returns>A byte array.</returns>
public
byte
[]
ToByteArray
()
{
return
Pack
(
_timestamp
,
_machine
,
_pid
,
_increment
);
}
/// <summary>
/// Returns a string representation of the value.
/// </summary>
/// <returns>A string representation of the value.</returns>
public
override
string
ToString
()
{
return
ToHexString
(
ToByteArray
());
}
/// <summary>
/// Parses a hex string into its equivalent byte array.
/// </summary>
/// <param name="s">The hex string to parse.</param>
/// <returns>The byte equivalent of the hex string.</returns>
public
static
byte
[]
ParseHexString
(
string
s
)
{
if
(
s
==
null
)
{
throw
new
ArgumentNullException
(
"s"
);
}
if
(
s
.
Length
%
2
==
1
)
{
throw
new
Exception
(
"The binary key cannot have an odd number of digits"
);
}
byte
[]
arr
=
new
byte
[
s
.
Length
>>
1
];
for
(
int
i
=
0
;
i
<
s
.
Length
>>
1
;
++
i
)
{
arr
[
i
]
=
(
byte
)((
GetHexVal
(
s
[
i
<<
1
])
<<
4
)
+
(
GetHexVal
(
s
[(
i
<<
1
)
+
1
])));
}
return
arr
;
}
/// <summary>
/// Converts a byte array to a hex string.
/// </summary>
/// <param name="bytes">The byte array.</param>
/// <returns>A hex string.</returns>
public
static
string
ToHexString
(
byte
[]
bytes
)
{
if
(
bytes
==
null
)
{
throw
new
ArgumentNullException
(
"bytes"
);
}
var
result
=
new
char
[
bytes
.
Length
*
2
];
for
(
int
i
=
0
;
i
<
bytes
.
Length
;
i
++)
{
var
val
=
_lookup32
[
bytes
[
i
]];
result
[
2
*
i
]
=
(
char
)
val
;
result
[
2
*
i
+
1
]
=
(
char
)(
val
>>
16
);
}
return
new
string
(
result
);
}
/// <summary>
/// Converts a DateTime to number of milliseconds since Unix epoch.
/// </summary>
/// <param name="dateTime">A DateTime.</param>
/// <returns>Number of seconds since Unix epoch.</returns>
public
static
long
ToMillisecondsSinceEpoch
(
DateTime
dateTime
)
{
var
utcDateTime
=
ToUniversalTime
(
dateTime
);
return
(
utcDateTime
-
__unixEpoch
).
Ticks
/
10000
;
}
/// <summary>
/// Converts a DateTime to UTC (with special handling for MinValue and MaxValue).
/// </summary>
/// <param name="dateTime">A DateTime.</param>
/// <returns>The DateTime in UTC.</returns>
public
static
DateTime
ToUniversalTime
(
DateTime
dateTime
)
{
if
(
dateTime
==
DateTime
.
MinValue
)
{
return
DateTime
.
SpecifyKind
(
DateTime
.
MinValue
,
DateTimeKind
.
Utc
);
}
else
if
(
dateTime
==
DateTime
.
MaxValue
)
{
return
DateTime
.
SpecifyKind
(
DateTime
.
MaxValue
,
DateTimeKind
.
Utc
);
}
else
{
return
dateTime
.
ToUniversalTime
();
}
}
private
static
int
GetHexVal
(
char
hex
)
{
int
val
=
(
int
)
hex
;
//For uppercase A-F letters:
//return val - (val < 58 ? 48 : 55);
//For lowercase a-f letters:
//return val - (val < 58 ? 48 : 87);
//Or the two combined, but a bit slower:
return
val
-
(
val
<
58
?
48
:
(
val
<
97
?
55
:
87
));
}
}
}
test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj
View file @
816fb33c
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp
1.1
</TargetFramework>
<TargetFramework>netcoreapp
2.0
</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>DotNetCore.CAP.MySql.Test</AssemblyName>
<AssemblyName>DotNetCore.CAP.MySql.Test</AssemblyName>
<PackageId>DotNetCore.CAP.MySql.Test</PackageId>
<PackageId>DotNetCore.CAP.MySql.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
@@ -24,19 +19,19 @@
...
@@ -24,19 +19,19 @@
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
0.0
" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
5.0-preview-20170810-02
" />
<PackageReference Include="MySqlConnector" Version="0.24.
0
" />
<PackageReference Include="MySqlConnector" Version="0.24.
2
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
2.0
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="xunit" Version="2.
2.0
" />
<PackageReference Include="xunit" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
1.1.2
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
1.1.1
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
2.0.0
" />
<PackageReference Include="Moq" Version="4.7.
63
" />
<PackageReference Include="Moq" Version="4.7.
99
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="
2.0.0
" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj
View file @
816fb33c
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp
1.1
</TargetFramework>
<TargetFramework>netcoreapp
2.0
</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>DotNetCore.CAP.SqlServer.Test</AssemblyName>
<AssemblyName>DotNetCore.CAP.SqlServer.Test</AssemblyName>
<PackageId>DotNetCore.CAP.SqlServer.Test</PackageId>
<PackageId>DotNetCore.CAP.SqlServer.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
@@ -24,21 +19,21 @@
...
@@ -24,21 +19,21 @@
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
0.0
" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
5.0-preview-20170810-02
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
2.0
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="xunit" Version="2.
2.0
" />
<PackageReference Include="xunit" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
1.1.2
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
1.1.1
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
2.0.0
" />
<PackageReference Include="Moq" Version="4.7.
63
" />
<PackageReference Include="Moq" Version="4.7.
99
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="
2.0.0
" />
<PackageReference Include="System.Data.SqlClient" Version="4.
3.1
" />
<PackageReference Include="System.Data.SqlClient" Version="4.
4.0
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="
2.0.0
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="
1.1.2
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="
2.0.0
" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
test/DotNetCore.CAP.SqlServer.Test/Properties/AssemblyInfo.cs
deleted
100644 → 0
View file @
5beb347b
using
System.Reflection
;
using
System.Runtime.InteropServices
;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
""
)]
[
assembly
:
AssemblyProduct
(
"DotNetCore.CAP.EntityFrameworkCore.Test"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[
assembly
:
ComVisible
(
false
)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[
assembly
:
Guid
(
"7442c942-1ddc-40e4-8f1b-654e721eaa45"
)]
\ No newline at end of file
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs
View file @
816fb33c
...
@@ -19,7 +19,7 @@ SELECT 'True'
...
@@ -19,7 +19,7 @@ SELECT 'True'
ELSE
ELSE
SELECT 'False'"
;
SELECT 'False'"
;
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
Assert
.
Equal
(
true
,
result
);
Assert
.
True
(
result
);
}
}
}
}
...
@@ -34,7 +34,7 @@ SELECT 'True'
...
@@ -34,7 +34,7 @@ SELECT 'True'
ELSE
ELSE
SELECT 'False'"
;
SELECT 'False'"
;
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
Assert
.
Equal
(
true
,
result
);
Assert
.
True
(
result
);
}
}
}
}
...
@@ -49,7 +49,7 @@ SELECT 'True'
...
@@ -49,7 +49,7 @@ SELECT 'True'
ELSE
ELSE
SELECT 'False'"
;
SELECT 'False'"
;
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
Assert
.
Equal
(
true
,
result
);
Assert
.
True
(
result
);
}
}
}
}
...
@@ -64,7 +64,7 @@ SELECT 'True'
...
@@ -64,7 +64,7 @@ SELECT 'True'
ELSE
ELSE
SELECT 'False'"
;
SELECT 'False'"
;
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
var
result
=
connection
.
QueryFirst
<
bool
>(
sql
);
Assert
.
Equal
(
true
,
result
);
Assert
.
True
(
result
);
}
}
}
}
}
}
...
...
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs
View file @
816fb33c
...
@@ -42,7 +42,7 @@ namespace DotNetCore.CAP.Test
...
@@ -42,7 +42,7 @@ namespace DotNetCore.CAP.Test
Assert
.
NotNull
(
bestCandidates
);
Assert
.
NotNull
(
bestCandidates
);
Assert
.
NotNull
(
bestCandidates
.
MethodInfo
);
Assert
.
NotNull
(
bestCandidates
.
MethodInfo
);
Assert
.
Equal
(
bestCandidates
.
MethodInfo
.
ReturnType
,
typeof
(
Task
)
);
Assert
.
Equal
(
typeof
(
Task
),
bestCandidates
.
MethodInfo
.
ReturnType
);
}
}
}
}
...
...
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
View file @
816fb33c
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp
1.1
</TargetFramework>
<TargetFramework>netcoreapp
2.0
</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>DotNetCore.CAP.Test</AssemblyName>
<AssemblyName>DotNetCore.CAP.Test</AssemblyName>
<PackageId>DotNetCore.CAP.Test</PackageId>
<PackageId>DotNetCore.CAP.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
@@ -15,14 +13,14 @@
...
@@ -15,14 +13,14 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
0.0
" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.
5.0-preview-20170810-02
" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
2.0
" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="xunit" Version="2.
2.0
" />
<PackageReference Include="xunit" Version="2.
3.0-beta3-build3705
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
1.1.2
" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="
2.0.0
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
1.1.1
" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="
2.0.0
" />
<PackageReference Include="Moq" Version="4.7.
63
" />
<PackageReference Include="Moq" Version="4.7.
99
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
1.1.2
" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="
2.0.0
" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs
View file @
816fb33c
...
@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Test
...
@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Test
fixture
.
ChangeState
(
message
,
state
,
mockTransaction
.
Object
);
fixture
.
ChangeState
(
message
,
state
,
mockTransaction
.
Object
);
// Assert
// Assert
Assert
.
Equal
(
message
.
StatusName
,
"s"
);
Assert
.
Equal
(
"s"
,
message
.
StatusName
);
Assert
.
Null
(
message
.
ExpiresAt
);
Assert
.
Null
(
message
.
ExpiresAt
);
Mock
.
Get
(
state
).
Verify
(
s
=>
s
.
Apply
(
message
,
mockTransaction
.
Object
),
Times
.
Once
);
Mock
.
Get
(
state
).
Verify
(
s
=>
s
.
Apply
(
message
,
mockTransaction
.
Object
),
Times
.
Once
);
mockTransaction
.
Verify
(
t
=>
t
.
UpdateMessage
(
message
),
Times
.
Once
);
mockTransaction
.
Verify
(
t
=>
t
.
UpdateMessage
(
message
),
Times
.
Once
);
...
@@ -48,7 +48,7 @@ namespace DotNetCore.CAP.Test
...
@@ -48,7 +48,7 @@ namespace DotNetCore.CAP.Test
fixture
.
ChangeState
(
message
,
state
,
mockTransaction
.
Object
);
fixture
.
ChangeState
(
message
,
state
,
mockTransaction
.
Object
);
// Assert
// Assert
Assert
.
Equal
(
message
.
StatusName
,
"s"
);
Assert
.
Equal
(
"s"
,
message
.
StatusName
);
Assert
.
NotNull
(
message
.
ExpiresAt
);
Assert
.
NotNull
(
message
.
ExpiresAt
);
mockTransaction
.
Verify
(
t
=>
t
.
UpdateMessage
(
message
),
Times
.
Once
);
mockTransaction
.
Verify
(
t
=>
t
.
UpdateMessage
(
message
),
Times
.
Once
);
mockTransaction
.
Verify
(
t
=>
t
.
CommitAsync
(),
Times
.
Never
);
mockTransaction
.
Verify
(
t
=>
t
.
CommitAsync
(),
Times
.
Never
);
...
...
test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs
View file @
816fb33c
...
@@ -39,7 +39,7 @@ namespace DotNetCore.CAP.Test
...
@@ -39,7 +39,7 @@ namespace DotNetCore.CAP.Test
Assert
.
NotNull
(
queueExecutorFactory
);
Assert
.
NotNull
(
queueExecutorFactory
);
var
publishExecutor
=
queueExecutorFactory
.
GetInstance
(
Models
.
MessageType
.
Publish
);
var
publishExecutor
=
queueExecutorFactory
.
GetInstance
(
Models
.
MessageType
.
Publish
);
Assert
.
Equal
(
null
,
publishExecutor
);
Assert
.
Null
(
publishExecutor
);
}
}
...
...
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