예제 #1
0
 public void Equality_SameCurrenciesAndRate_True()
 {
     Assert.That(fiberUnit.Equals(fiberUnit), Is.True);
     Assert.That(fiberUnit.Equals(anotherFiberUnit), Is.True);
     Assert.That(anotherFiberUnit.Equals(fiberUnit), Is.True);
     Assert.That(fiberUnit == anotherFiberUnit, Is.True);
     Assert.That(anotherFiberUnit == fiberUnit, Is.True);
 }
        public void WhenTheAreEquel_ThenComparingShouldBeTrueOtherwiseFalse(ExchangeRate fx1, ExchangeRate fx2, bool areEqual)
        {
            if (areEqual)
            {
                fx1.Should().Be(fx2);
            }
            else
            {
                fx1.Should().NotBe(fx2);
            }

            if (areEqual)
            {
                fx1.GetHashCode().Should().Be(fx2.GetHashCode()); //using GetHashCode()
            }
            else
            {
                fx1.GetHashCode().Should().NotBe(fx2.GetHashCode()); //using GetHashCode()
            }
            fx1.Equals(fx2).Should().Be(areEqual);                   //using Equal()
            ExchangeRate.Equals(fx1, fx2).Should().Be(areEqual);     //using static Equals()
            (fx1 == fx2).Should().Be(areEqual);                      //using Euality operators
            (fx1 != fx2).Should().Be(!areEqual);                     //using Euality operators
        }