Esempio n. 1
0
 public void TestReferenceEquals()
 {
     var z = new ComplexNumber(1, 2);
     // ReSharper disable EqualExpressionComparison
     (z == z).ShouldBeTrue();
     // ReSharper restore EqualExpressionComparison
 }
Esempio n. 2
0
 public void TestEqualityNull()
 {
     var z = new ComplexNumber(1, 2);
     // ReSharper disable ConditionIsAlwaysTrueOrFalse
     (z == null).ShouldBeFalse();
     // ReSharper restore ConditionIsAlwaysTrueOrFalse
 }
Esempio n. 3
0
 public void TestNotEquals()
 {
     var z = new ComplexNumber(1, 2);
     var w = new ComplexNumber(1, 2);
     var x = new ComplexNumber(3, 2);
     (z != x).ShouldBeTrue();
     (z != w).ShouldBeFalse();
 }
Esempio n. 4
0
 public void ComplexNumberHashcodeShouldBeAsExpected()
 {
     var z = new ComplexNumber(1, 2);
     z.GetHashCode().ShouldEqual(z.Re.GetHashCode() ^ z.Im.GetHashCode());
 }
Esempio n. 5
0
 public ComplexNumber Product(ComplexNumber w)
 {
     return new ComplexNumber(X * w.X - Y * w.Y,
         X * w.Y + Y * w.X);
 }
Esempio n. 6
0
 protected bool Equals(ComplexNumber other)
 {
     // ReSharper disable CompareOfFloatsByEqualityOperator
     return Re == other.Re && Im == other.Im;
     // ReSharper restore CompareOfFloatsByEqualityOperator
 }