Exemplo n.º 1
0
        public void Equals_CaseInsensitive(string expectedName, string actualName)
        {
            // set up
            var expected = new Candidate(expectedName);

            // act
            var actual = new Candidate(actualName);

            // assert
            if (StringComparer.OrdinalIgnoreCase.Equals(expectedName, actualName))
            {
                Assert.Equal(expectedName, actualName, ignoreCase: true);
                Assert.Equal(expected, actual);
                Assert.True(expected.Equals((Candidate)actual));
                Assert.True(expected.Equals((object)actual));
                Assert.True(expected == actual);
                Assert.False(expected != actual);

                // hashcode should always be the same for two objects that are equal
                Assert.Equal(expected.GetHashCode(), actual.GetHashCode());
            }
            else
            {
                Assert.NotEqual(expectedName, actualName, StringComparer.OrdinalIgnoreCase);
                Assert.NotEqual(expected, actual);
                Assert.False(expected.Equals((Candidate)actual));
                Assert.False(expected.Equals((object)actual));
                Assert.False(expected == actual);
                Assert.True(expected != actual);
                // hashcode is not guaranteed different for unequal objects
            }
        }
Exemplo n.º 2
0
 /// <inheritdoc/>
 public virtual bool Equals(Vote v)
 {
     if (v is null)
     {
         return(false);
     }
     else if (ReferenceEquals(this, v))
     {
         return(true);
     }
     return(Candidate.Equals(v.Candidate) && Value.Equals(v.Value));
 }