public void TestSubstract() { Complex result = new Complex(); result = a.Substract(b); Complex expected = new Complex(); expected.Re = a.Re - b.Re; expected.Im = a.Im - b.Im; Assert.AreEqual(result.Re, expected.Re); Assert.AreEqual(result.Im, expected.Im); }
public void TestDivide() { Complex result = new Complex(); result = a.Divide(b); Complex expected = new Complex(); expected.Re = ((a.Re * b.Re) + (a.Im * b.Im)) / ((b.Re * b.Re) + (b.Im * b.Im)); expected.Im = ((a.Im * b.Re) + (a.Re * b.Im)) / ((b.Re * b.Re) + (b.Im * b.Im)); Assert.AreEqual(result.Re, expected.Re); Assert.AreEqual(result.Im, expected.Im); }
public void TestMultiply() { Complex result = new Complex(); result = a.Multiply(b); Complex expected = new Complex(); expected.Re = a.Re * b.Re - a.Im * b.Im; expected.Im = a.Im * b.Re + a.Re * b.Im; Assert.AreEqual(result.Re, expected.Re); Assert.AreEqual(result.Im, expected.Im); }
public void TestAdd() { Complex result = new Complex(); result = a.Add(b); Complex expected = new Complex(); expected.Re = a.Re + b.Re; expected.Im = a.Im + b.Im; Assert.AreEqual(result.Re,expected.Re); Assert.AreEqual(result.Im,expected.Im); }