This is an automated email from the ASF dual-hosted git repository. blankensteiner pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git
The following commit(s) were added to refs/heads/master by this push: new ac1e228 Update test method names to follow Feature/MethodName_Given[StateUnderTest]_Should[ExpectedBehavior] ac1e228 is described below commit ac1e228a47bd0c8d45a3314b5cca6f67aa3772e5 Author: Daniel Blankensteiner <d...@danskecommodities.com> AuthorDate: Wed Sep 2 09:28:44 2020 +0200 Update test method names to follow Feature/MethodName_Given[StateUnderTest]_Should[ExpectedBehavior] --- src/DotPulsar/MessageId.cs | 2 +- tests/DotPulsar.Tests/MessageIdTests.cs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/DotPulsar/MessageId.cs b/src/DotPulsar/MessageId.cs index c01535c..55ab235 100644 --- a/src/DotPulsar/MessageId.cs +++ b/src/DotPulsar/MessageId.cs @@ -79,7 +79,7 @@ namespace DotPulsar => !(other is null) && LedgerId == other.LedgerId && EntryId == other.EntryId && Partition == other.Partition && BatchIndex == other.BatchIndex; public static bool operator ==(MessageId x, MessageId y) - => object.ReferenceEquals(x, y) || (!object.ReferenceEquals(x, null) && x.Equals(y)); + => ReferenceEquals(x, y) || (x is object && x.Equals(y)); public static bool operator !=(MessageId x, MessageId y) => !(x == y); diff --git a/tests/DotPulsar.Tests/MessageIdTests.cs b/tests/DotPulsar.Tests/MessageIdTests.cs index 12e1c61..7b1652b 100644 --- a/tests/DotPulsar.Tests/MessageIdTests.cs +++ b/tests/DotPulsar.Tests/MessageIdTests.cs @@ -1,4 +1,4 @@ -/* +/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,54 +23,59 @@ namespace DotPulsar.Tests public class MessageIdTests { [Fact] - public void MessageId_Equality_SameReference() + public void Equals_GivenTheSameObject_ShouldBeEqual() { var m1 = new MessageId(1234, 5678, 9876, 5432); var m2 = m1; + Assert.True(m1.Equals(m2)); Assert.True(m1 == m2); Assert.False(m1 != m2); } [Fact] - public void MessageId_Equality_SameValues() + public void Equals_GivenTheSameValues_ShouldBeEqual() { var m1 = new MessageId(1234, 5678, 9876, 5432); var m2 = new MessageId(1234, 5678, 9876, 5432); + Assert.True(m1.Equals(m2)); Assert.True(m1 == m2); Assert.False(m1 != m2); } [Fact] - public void MessageId_Inequality_DifferentValues() + public void Equals_GivenDifferentValues_ShouldNotBeEqual() { var m1 = new MessageId(1234, 5678, 9876, 5432); var m2 = new MessageId(9876, 6432, 1234, 6678); + Assert.False(m1.Equals(m2)); Assert.False(m1 == m2); Assert.True(m1 != m2); } [Fact] - public void MessageId_Equality_Null() + public void Equals_GivenAllNull_ShouldBeEqual() { MessageId m1 = null; MessageId m2 = null; + Assert.True(m1 == m2); Assert.True(m1 == null); Assert.False(m1 != m2); } [Fact] - public void MessageId_Inequality_NotNull() + public void Equals_GivenOneNull_ShouldNotBeEqual() { var m1 = new MessageId(1234, 5678, 9876, 5432); MessageId m2 = null; + Assert.False(m1 == null); Assert.False(m1 == m2); Assert.False(m1.Equals(m2)); Assert.True(m1 != m2); } } -} \ No newline at end of file +}