예제 #1
0
            public void 共役が取得できること(int input, int expected)
            {
                var pin       = new PurelyImaginaryNumber(input);
                var conjugate = new PurelyImaginaryNumber(expected);

                Assert.AreEqual(conjugate, pin.GetConjugate());
            }
예제 #2
0
            public void 虚部が同一の純虚数のハッシュコードが一致すること()
            {
                var pin   = new PurelyImaginaryNumber(-1);
                var other = new PurelyImaginaryNumber(-1);

                Assert.AreEqual(pin.GetHashCode(), other.GetHashCode());
            }
예제 #3
0
            public void 虚部が同じ純虚数を同一と判定しそれ以外は異なると判定すること(int input1, int input2, bool expected)
            {
                var pin1 = new PurelyImaginaryNumber(input1);
                var pin2 = new PurelyImaginaryNumber(input2);

                Assert.AreEqual(expected, pin1.Equals(pin2));
            }
예제 #4
0
        public override bool Equals(object obj)
        {
            if (obj == null || this.GetType() != obj.GetType())
            {
                return(false);
            }
            PurelyImaginaryNumber c = (PurelyImaginaryNumber)obj;

            return(this.imaginaryPart == c.imaginaryPart);
        }
예제 #5
0
            public void 純虚数と純虚数以外のオブジェクト比較がfalseとなること(object other)
            {
                var pin = new PurelyImaginaryNumber(1);

                Assert.IsFalse(pin.Equals(other));
            }
예제 #6
0
            public void 純虚数の文字列表記が合っていること(int input, string expected)
            {
                var pin = new PurelyImaginaryNumber(input);

                Assert.AreEqual(expected, pin.ToString());
            }
예제 #7
0
            public void 虚部1の純虚数が生成できること()
            {
                var pin = new PurelyImaginaryNumber(1);

                Assert.AreEqual(1, pin.ImaginaryNumber);
            }