public void FileReadTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0) }); Assert.AreEqual(true, test.ToString() == test.ToString()); }
public void Generate(int minutes) { var timerThread = new Thread(() => MyTimer(minutes)); timerThread.Start(); int membersCount = new Random().Next(0, 11); string result; var polinom = new Polinom(); polinom.items = new List <PolinomItem>(); polinom.freeConstant = new Random().Next(-200, 201); for (int i = 0; i <= membersCount; i++) { Random randConstant = new Random(DateTime.Now.Millisecond + i); Random randDegree = new Random(DateTime.Now.Millisecond + 1 + i); var polinomItem = new PolinomItem( randConstant.Next(-10, 11), randDegree.Next(0, 11) ); polinom.items.Add(polinomItem); } result = "Generated polinom: " + polinom.ToString(); timerThread.Join(); _data.SaveAsTxt(polinom); }
public void Mult_1_2_3_and_4_5_returned_4_13_22_15() { double[] kpol = { 1, 2, 3 }; double[] kpol2 = { 4, 5 }; Polinom pol = new Polinom(2, kpol); Polinom pol2 = new Polinom(1, kpol2); double[] kexpected = { 4, 13, 22, 15 }; Polinom expected = new Polinom(3, kexpected); Assert.AreEqual(expected.ToString(), MultPolinom.Multiplication(pol, pol2).ToString()); }
public void ToStringTest_Polinom_String() { int variableX = 3; int[] array = { 1, 2, 3, 4 }; string expectedResult = "The example: 1*3^4 + 2*3^3 + 3*3^2 + 4*3 = 0"; Polinom polinom1 = new Polinom(variableX, array); string actualResult = polinom1.ToString(); Assert.AreEqual(expectedResult, actualResult); }
public void ToStringTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0) }); Assert.AreEqual("5x^4+5x^3+1x^2-11= 0", test.ToString()); }
public void SubTest_3andArray1and2_SubPolinom() { int variableX = 3; int number = 2; int[] array = { 1, 2, 3, 4 }; int[] expectedArrey = { -1, 0, 1, 2 }; Polinom polinom1 = new Polinom(variableX, array); Polinom expectedPolinom = new Polinom(variableX, expectedArrey); Polinom actualPolinom = polinom1 - number; Assert.AreEqual(expectedPolinom.ToString(), actualPolinom.ToString()); }
public void DeleteOddTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (6, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-12, 0) }); test.DeleteOdd(); var test2 = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (6, 3), new Tuple <double, int> (-12, 0) }); Assert.AreEqual(true, test.ToString() == test2.ToString()); }
public void Derivate() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (6, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-12, 0) }); test.Derivate(); var test2 = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (20, 3), new Tuple <double, int> (18, 2), new Tuple <double, int> (2, 1), }); Assert.AreEqual(true, test.ToString() == test2.ToString()); }
public void InsertTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0) }); test.Insert(16, 4); var test2 = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (21, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0) }); Assert.AreEqual(true, test.ToString() == test2.ToString()); }
public void SumTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0) }); test.Sum(new Odnochlen(1, 4)); var test2 = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (6, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0), new Tuple <double, int> (0, 0) }); Assert.AreEqual(true, test2.ToString() == test.ToString()); }
public void CombineTest() { var test = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-11, 0), new Tuple <double, int> (-11, 0) }); test.Combine(); var test2 = new Polinom(new List <Tuple <double, int> > { new Tuple <double, int> (5, 4), new Tuple <double, int> (5, 3), new Tuple <double, int> (1, 2), new Tuple <double, int> (-22, 0) }); Assert.AreEqual(true, test2.ToString() == test.ToString()); }