예제 #1
0
 public void TestReferenceEquals()
 {
     var z = new ComplexNumber(1, 2);
     // ReSharper disable EqualExpressionComparison
     (z == z).ShouldBeTrue();
     // ReSharper restore EqualExpressionComparison
 }
예제 #2
0
 public void TestEqualityNull()
 {
     var z = new ComplexNumber(1, 2);
     // ReSharper disable ConditionIsAlwaysTrueOrFalse
     (z == null).ShouldBeFalse();
     // ReSharper restore ConditionIsAlwaysTrueOrFalse
 }
예제 #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();
 }
예제 #4
0
 public void ComplexNumberHashcodeShouldBeAsExpected()
 {
     var z = new ComplexNumber(1, 2);
     z.GetHashCode().ShouldEqual(z.Re.GetHashCode() ^ z.Im.GetHashCode());
 }
예제 #5
0
 public ComplexNumber Product(ComplexNumber w)
 {
     return new ComplexNumber(X * w.X - Y * w.Y,
         X * w.Y + Y * w.X);
 }
예제 #6
0
 protected bool Equals(ComplexNumber other)
 {
     // ReSharper disable CompareOfFloatsByEqualityOperator
     return Re == other.Re && Im == other.Im;
     // ReSharper restore CompareOfFloatsByEqualityOperator
 }