public void NotEqualsTest2()
 {
     Polynomial testPoly = new Polynomial(32, 4, 6, 0, 47, 2, 4);
     bool expected = testPoly != poly1;
     Assert.AreEqual(expected, true);
 }
 public void EqualsTest1()
 {
     Polynomial testPoly = new Polynomial(1, 15, 0, 45, 1, 0, 14, 3, 0);
     bool expected = testPoly == poly1;
     Assert.AreEqual(expected, true);
 }
 public void EqualsTest3()
 {
     Polynomial testPoly = new Polynomial(1, 15, 0, 45, 1, 0, 14, 3, 0);
     var expected = testPoly.Equals(poly1);
     Assert.AreEqual(expected, true);
 }
        public static Polynomial operator +(Polynomial poly1, Polynomial poly2)
        {
            if (poly1 == null && poly2 == null)
                throw new ArgumentNullException("Cannot to sum null refferences.");

            if (poly1 == null || poly2 == null)
                throw new ArgumentNullException("Cannot to sum polynomial with null.");
            
            Polynomial newPoly;
            if (poly1.Degree >= poly2.Degree)
            {
                newPoly = new Polynomial(poly1.Degree);
                for (int i = 0; i <= newPoly.Degree; i++)
                {
                    if (i <= poly2.Degree)
                        newPoly[i] = poly1[i] + poly2[i];
                    else newPoly[i] = poly1[i];
                }
            }
            else
            {
                newPoly = new Polynomial(poly2.Degree);
                for (int i = 0; i <= newPoly.Degree; i++)
                {
                    if (i <= poly1.Degree)
                        newPoly[i] = poly1[i] + poly2[i];
                    else newPoly[i] = poly2[i];
                }
            }
            return newPoly;
        }
        public static Polynomial operator /(Polynomial poly, double coefficient)
        {
            if (poly == null)
                throw new ArgumentNullException("Cannot to divide null refference.");
            
            if (coefficient == 0)
            {
                throw new DivideByZeroException();
            }

            Polynomial newPoly = new Polynomial(poly.Degree);

            for (int i = 0; i <= newPoly.Degree; i++)
            {
                newPoly[i] = poly[i] / coefficient;
            }
            return newPoly;
        }
        public static Polynomial operator *(Polynomial poly, double coefficient)
        {
            if (poly == null)
                throw new ArgumentNullException("Cannot to multiply null refference.");
            
            Polynomial newPoly = new Polynomial(poly.Degree);

            for (int i = 0; i <= newPoly.Degree; i++)
            {
                newPoly[i] = poly[i] * coefficient;
            }
            return newPoly;
        }
        public static Polynomial operator *(Polynomial poly1, Polynomial poly2)
        {
            if (poly1 == null && poly2 == null)
                throw new ArgumentNullException("Cannot to multiply null refferences.");

            if (poly1 == null || poly2 == null)
                throw new ArgumentNullException("Cannot to multiply polynomial with null.");
            
            Polynomial newPoly = new Polynomial(poly1.Degree + poly2.Degree);

            for (int i = 0; i <= poly1.Degree; i++)
            {
                for (int j = 0; j <= poly2.Degree; j++)
                {
                    newPoly[i + j] += poly1[i] * poly2[j];
                }
            }
            return newPoly;

        }
 public static Polynomial operator -(Polynomial poly)
 {
     if (poly == null)
         throw new ArgumentNullException("Cannot to negate null refference.");
     
     Polynomial newPoly = new Polynomial(poly.Degree);
     for (int i = 0; i <= poly.Degree; i++)
     {
         newPoly[i] = -poly[i];
     }
     return newPoly;
 }