diff --git a/.gitignore b/.gitignore index 96cda33..d7fe0b1 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ bin/ /.idea/.idea.CAP /.idea/.idea.CAP /.idea -Properties \ No newline at end of file +Properties +/pack.bat diff --git a/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj b/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj index 89bd201..f27aee1 100644 --- a/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj +++ b/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj @@ -3,10 +3,15 @@ - netstandard1.6; + netstandard2.0; DotNetCore.CAP.Kafka $(PackageTags);Kafka + + + + + diff --git a/src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj b/src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj index d750aaf..9ee70d2 100644 --- a/src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj +++ b/src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj @@ -3,20 +3,16 @@ - netstandard1.6;netstandard2.0; + netstandard2.0; DotNetCore.CAP.MySql $(PackageTags);MySQL - - TRACE;DEBUG - - - - - + + + diff --git a/src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj b/src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj index a49961e..f34d60b 100644 --- a/src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj +++ b/src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj @@ -3,19 +3,15 @@ - netstandard1.6;netstandard2.0; + netstandard2.0; DotNetCore.CAP.PostgreSql $(PackageTags);PostgreSQL - - TRACE;DEBUG - - - - + + diff --git a/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj b/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj index 52e7844..c92e44b 100644 --- a/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj +++ b/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj @@ -3,7 +3,7 @@ - netstandard1.6; + netstandard2.0; DotNetCore.CAP.RabbitMQ $(PackageTags);RabbitMQ diff --git a/src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj b/src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj index 7592ae4..8dc779f 100644 --- a/src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj +++ b/src/DotNetCore.CAP.SqlServer/DotNetCore.CAP.SqlServer.csproj @@ -3,19 +3,15 @@ - netstandard1.6;netstandard2.0; + netstandard2.0; DotNetCore.CAP.SqlServer $(PackageTags);SQL Server - - TRACE;DEBUG - - - - + + diff --git a/src/DotNetCore.CAP/DotNetCore.CAP.csproj b/src/DotNetCore.CAP/DotNetCore.CAP.csproj index 8b9c660..ab566f9 100644 --- a/src/DotNetCore.CAP/DotNetCore.CAP.csproj +++ b/src/DotNetCore.CAP/DotNetCore.CAP.csproj @@ -3,28 +3,21 @@ - netstandard1.6;netstandard2.0; + netstandard2.0; DotNetCore.CAP $(PackageTags); - - - - + + + + - - - - - + + - - - - diff --git a/src/DotNetCore.CAP/Infrastructure/ObjectId.cs b/src/DotNetCore.CAP/Infrastructure/ObjectId.cs new file mode 100644 index 0000000..138690e --- /dev/null +++ b/src/DotNetCore.CAP/Infrastructure/ObjectId.cs @@ -0,0 +1,539 @@ +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 +{ + /// Represents an ObjectId + /// + [Serializable] + public struct ObjectId : IComparable, IEquatable + { + // 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 + /// + /// Initializes a new instance of the ObjectId class. + /// + /// The bytes. + public ObjectId(byte[] bytes) + { + if (bytes == null) + { + throw new ArgumentNullException("bytes"); + } + Unpack(bytes, out _timestamp, out _machine, out _pid, out _increment); + } + + /// + /// Initializes a new instance of the ObjectId class. + /// + /// The timestamp (expressed as a DateTime). + /// The machine hash. + /// The PID. + /// The increment. + public ObjectId(DateTime timestamp, int machine, short pid, int increment) + : this(GetTimestampFromDateTime(timestamp), machine, pid, increment) + { + } + + /// + /// Initializes a new instance of the ObjectId class. + /// + /// The timestamp. + /// The machine hash. + /// The PID. + /// The increment. + 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; + } + + /// + /// Initializes a new instance of the ObjectId class. + /// + /// The value. + 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 + /// + /// Gets an instance of ObjectId where the value is empty. + /// + public static ObjectId Empty + { + get { return __emptyInstance; } + } + + // public properties + /// + /// Gets the timestamp. + /// + public int Timestamp + { + get { return _timestamp; } + } + + /// + /// Gets the machine. + /// + public int Machine + { + get { return _machine; } + } + + /// + /// Gets the PID. + /// + public short Pid + { + get { return _pid; } + } + + /// + /// Gets the increment. + /// + public int Increment + { + get { return _increment; } + } + + /// + /// Gets the creation time (derived from the timestamp). + /// + public DateTime CreationTime + { + get { return __unixEpoch.AddSeconds(_timestamp); } + } + + // public operators + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId + /// True if the first ObjectId is less than the second ObjectId. + public static bool operator <(ObjectId lhs, ObjectId rhs) + { + return lhs.CompareTo(rhs) < 0; + } + + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId + /// True if the first ObjectId is less than or equal to the second ObjectId. + public static bool operator <=(ObjectId lhs, ObjectId rhs) + { + return lhs.CompareTo(rhs) <= 0; + } + + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId. + /// True if the two ObjectIds are equal. + public static bool operator ==(ObjectId lhs, ObjectId rhs) + { + return lhs.Equals(rhs); + } + + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId. + /// True if the two ObjectIds are not equal. + public static bool operator !=(ObjectId lhs, ObjectId rhs) + { + return !(lhs == rhs); + } + + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId + /// True if the first ObjectId is greather than or equal to the second ObjectId. + public static bool operator >=(ObjectId lhs, ObjectId rhs) + { + return lhs.CompareTo(rhs) >= 0; + } + + /// + /// Compares two ObjectIds. + /// + /// The first ObjectId. + /// The other ObjectId + /// True if the first ObjectId is greather than the second ObjectId. + public static bool operator >(ObjectId lhs, ObjectId rhs) + { + return lhs.CompareTo(rhs) > 0; + } + + // public static methods + /// + /// Generates a new ObjectId with a unique value. + /// + /// An ObjectId. + public static ObjectId GenerateNewId() + { + return GenerateNewId(GetTimestampFromDateTime(DateTime.UtcNow)); + } + + /// + /// Generates a new ObjectId with a unique value (with the timestamp component based on a given DateTime). + /// + /// The timestamp component (expressed as a DateTime). + /// An ObjectId. + public static ObjectId GenerateNewId(DateTime timestamp) + { + return GenerateNewId(GetTimestampFromDateTime(timestamp)); + } + + /// + /// Generates a new ObjectId with a unique value (with the given timestamp). + /// + /// The timestamp component. + /// An ObjectId. + 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); + } + + /// + /// Generates a new ObjectId string with a unique value. + /// + /// The string value of the new generated ObjectId. + public static string GenerateNewStringId() + { + return GenerateNewId().ToString(); + } + + /// + /// Packs the components of an ObjectId into a byte array. + /// + /// The timestamp. + /// The machine hash. + /// The PID. + /// The increment. + /// A byte array. + 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; + } + + /// + /// Parses a string and creates a new ObjectId. + /// + /// The string value. + /// A ObjectId. + 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)); + } + + /// + /// Unpacks a byte array into the components of an ObjectId. + /// + /// A byte array. + /// The timestamp. + /// The machine hash. + /// The PID. + /// The increment. + 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 + /// + /// 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. + /// + [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 + /// + /// Compares this ObjectId to another ObjectId. + /// + /// The other ObjectId. + /// A 32-bit signed integer that indicates whether this ObjectId is less than, equal to, or greather than the other. + 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); + } + + /// + /// Compares this ObjectId to another ObjectId. + /// + /// The other ObjectId. + /// True if the two ObjectIds are equal. + public bool Equals(ObjectId rhs) + { + return + _timestamp == rhs._timestamp && + _machine == rhs._machine && + _pid == rhs._pid && + _increment == rhs._increment; + } + + /// + /// Compares this ObjectId to another object. + /// + /// The other object. + /// True if the other object is an ObjectId and equal to this one. + public override bool Equals(object obj) + { + if (obj is ObjectId) + { + return Equals((ObjectId)obj); + } + else + { + return false; + } + } + + /// + /// Gets the hash code. + /// + /// The hash code. + 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; + } + + /// + /// Converts the ObjectId to a byte array. + /// + /// A byte array. + public byte[] ToByteArray() + { + return Pack(_timestamp, _machine, _pid, _increment); + } + + /// + /// Returns a string representation of the value. + /// + /// A string representation of the value. + public override string ToString() + { + return ToHexString(ToByteArray()); + } + + /// + /// Parses a hex string into its equivalent byte array. + /// + /// The hex string to parse. + /// The byte equivalent of the hex string. + 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; + } + /// + /// Converts a byte array to a hex string. + /// + /// The byte array. + /// A hex string. + 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); + } + /// + /// Converts a DateTime to number of milliseconds since Unix epoch. + /// + /// A DateTime. + /// Number of seconds since Unix epoch. + public static long ToMillisecondsSinceEpoch(DateTime dateTime) + { + var utcDateTime = ToUniversalTime(dateTime); + return (utcDateTime - __unixEpoch).Ticks / 10000; + } + /// + /// Converts a DateTime to UTC (with special handling for MinValue and MaxValue). + /// + /// A DateTime. + /// The DateTime in UTC. + 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)); + } + } +} diff --git a/test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj b/test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj index cf89b39..1694331 100644 --- a/test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj +++ b/test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj @@ -1,16 +1,11 @@  - netcoreapp1.1 + netcoreapp2.0 true DotNetCore.CAP.MySql.Test DotNetCore.CAP.MySql.Test true - $(PackageTargetFallback);dnxcore50;portable-net451+win8 - 1.1.1 - false - false - false @@ -24,19 +19,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj b/test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj index 177d825..bd29d9b 100644 --- a/test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj +++ b/test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj @@ -1,16 +1,11 @@  - netcoreapp1.1 + netcoreapp2.0 true DotNetCore.CAP.SqlServer.Test DotNetCore.CAP.SqlServer.Test true - $(PackageTargetFallback);dnxcore50;portable-net451+win8 - 1.1.1 - false - false - false @@ -24,21 +19,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/test/DotNetCore.CAP.SqlServer.Test/Properties/AssemblyInfo.cs b/test/DotNetCore.CAP.SqlServer.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index a995715..0000000 --- a/test/DotNetCore.CAP.SqlServer.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -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 diff --git a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs index 38fb6c1..af1fdac 100644 --- a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs +++ b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs @@ -19,7 +19,7 @@ SELECT 'True' ELSE SELECT 'False'"; var result = connection.QueryFirst(sql); - Assert.Equal(true, result); + Assert.True(result); } } @@ -34,7 +34,7 @@ SELECT 'True' ELSE SELECT 'False'"; var result = connection.QueryFirst(sql); - Assert.Equal(true, result); + Assert.True(result); } } @@ -49,7 +49,7 @@ SELECT 'True' ELSE SELECT 'False'"; var result = connection.QueryFirst(sql); - Assert.Equal(true, result); + Assert.True(result); } } @@ -64,7 +64,7 @@ SELECT 'True' ELSE SELECT 'False'"; var result = connection.QueryFirst(sql); - Assert.Equal(true, result); + Assert.True(result); } } } diff --git a/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs b/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs index 1fc5ca8..97dd29b 100644 --- a/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs +++ b/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs @@ -42,7 +42,7 @@ namespace DotNetCore.CAP.Test Assert.NotNull(bestCandidates); Assert.NotNull(bestCandidates.MethodInfo); - Assert.Equal(bestCandidates.MethodInfo.ReturnType, typeof(Task)); + Assert.Equal(typeof(Task), bestCandidates.MethodInfo.ReturnType); } } diff --git a/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj b/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj index 81b5e2d..27bf741 100644 --- a/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj +++ b/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj @@ -1,13 +1,11 @@  - netcoreapp1.1 + netcoreapp2.0 true DotNetCore.CAP.Test DotNetCore.CAP.Test true - $(PackageTargetFallback);dnxcore50;portable-net451+win8 - 1.1.1 @@ -15,14 +13,14 @@ - + - - - - - - + + + + + + diff --git a/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs b/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs index 51101bd..b57692b 100644 --- a/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs +++ b/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs @@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Test fixture.ChangeState(message, state, mockTransaction.Object); // Assert - Assert.Equal(message.StatusName, "s"); + Assert.Equal("s", message.StatusName); Assert.Null(message.ExpiresAt); Mock.Get(state).Verify(s => s.Apply(message, mockTransaction.Object), Times.Once); mockTransaction.Verify(t => t.UpdateMessage(message), Times.Once); @@ -48,7 +48,7 @@ namespace DotNetCore.CAP.Test fixture.ChangeState(message, state, mockTransaction.Object); // Assert - Assert.Equal(message.StatusName, "s"); + Assert.Equal("s", message.StatusName); Assert.NotNull(message.ExpiresAt); mockTransaction.Verify(t => t.UpdateMessage(message), Times.Once); mockTransaction.Verify(t => t.CommitAsync(), Times.Never); diff --git a/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs b/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs index f1bf1e3..a5fef69 100644 --- a/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs +++ b/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs @@ -39,7 +39,7 @@ namespace DotNetCore.CAP.Test Assert.NotNull(queueExecutorFactory); var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish); - Assert.Equal(null, publishExecutor); + Assert.Null(publishExecutor); }