예제 #1
0
        public void PolynomEqualsTest()
        {
            Polynomial a = new Polynomial(new double[] { 1.1, 0, 3.3 });
            Polynomial b = new Polynomial(new double[] { 1.1, 0, 3.3 });

            bool expected = true;
            bool actual = a == b;
            Assert.AreEqual(expected,actual);
        }
예제 #2
0
        public void PolynomAdditionTest()
        {
            Polynomial a = new Polynomial(new double[] { 1.1, 2.2, 3.3, 0, -14.4 });
            Polynomial b = new Polynomial(new double[] { 1.1, 2.2, 3.3, 0, -14.4 });

            Polynomial expected = new Polynomial(new double[] { 2.2, 4.4, 6.6, 0, -28.8 });
            Polynomial actual = a + b;
            CollectionAssert.AreEqual(expected.Coefficients,actual.Coefficients);
        }
예제 #3
0
        public void PolynomSubtractionTest()
        {
            Polynomial a = new Polynomial(new double[] { 1.1, 2.2, 3.3, 0, -14.4 });
            Polynomial b = new Polynomial(new double[] { 1.1, 2.2, 3.3, 0, -14.4 });

            Polynomial expected = new Polynomial(new double[] { 0, 0, 0, 0, 0 });
            Polynomial actual = a - b;
            bool result = expected == actual;
            CollectionAssert.AreEqual(expected.Coefficients, actual.Coefficients);
        }
예제 #4
0
        public void PolynomMultiplicationTest()
        {
            Polynomial a = new Polynomial(new double[] { 1.1, 0, 3.3 });
            Polynomial b = new Polynomial(new double[] { 1.1, 0, 3.3 });

            Polynomial expected = new Polynomial(new double[] { 1.21, 0, 7.26, 0, 10.89 });
            Polynomial actual = a * b;
            bool isEqual = expected == actual;
            Assert.AreEqual(true, isEqual);
        }
예제 #5
0
 public void PolynomWithEmptyArray_ShouldThrowException()
 {
     Polynomial a = new Polynomial(new double[] {});
     Assert.Fail();
 }