public void GetSystemSolution_2() { // Log file path string logfilepath = "../../Test_Data/TinyMathTest/MathHelperTest/log.txt"; MathHelper mHelper = new MathHelper(logfilepath); // Predefined count of linear equation in the system int LinearEquationCount = 2; // Predefined count of unknown members in the system int UnknownCount = 2; // Input strings string str_1 = "-6.78x+0.69y+5z=8"; string str_2 = "-78x-12.69y+z=-28.56"; // List with strings List<string> strList = new List<string>(); strList.Add(str_1); strList.Add(str_2); // Actual value string actualResult = mHelper.TrySolveLinearEquationSystem(LinearEquationCount, UnknownCount, strList); // Expected value string expectedResult = "Wrong input system. " + "Check the input data for pattern matching " + "(look at the example)."; // Asserts Assert.AreEqual(expectedResult, actualResult); }
public void GetSystemSolution_4() { // Log file path string logfilepath = "../../Test_Data/TinyMathTest/MathHelperTest/log.txt"; MathHelper mHelper = new MathHelper(logfilepath); // Predefined count of linear equation in the system int LinearEquationCount = 3; // Predefined count of unknown members in the system int UnknownCount = 3; // Input strings string str_1 = "-6x+9y+5z=8"; string str_2 = "-7x-12y+z=-28"; string str_3 = "5x+6y+z=-28"; // List with strings List<string> strList = new List<string>(); strList.Add(str_1); strList.Add(str_2); strList.Add(str_3); // Actual value string actualResult = mHelper.TrySolveLinearEquationSystem(LinearEquationCount, UnknownCount, strList); // Expected value string expectedResult = "x: -8,70588235294118 y: 5,80392156862745 z: -19,2941176470588 "; // Asserts Assert.AreEqual(expectedResult, actualResult); }
// GetSolutionBtn click event handler // Using TinyMath Library protected void GetSolutionBtn_Click(object sender, EventArgs e) { // Log file path string logfilepath = "MathHelper_log.txt"; MathHelper mHelper = new MathHelper(logfilepath); // Input strings with linear equations string[] stringSeparators = new string[] {"\r\n"}; string[] inputStrings = leSystem.Text.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); // Try to solve the system lesSolutionText.Text = mHelper.TrySolveLinearEquationSystem( Convert.ToInt32(EqutionsCount.Text), Convert.ToInt32(UnknownCount.Text), inputStrings.ToList<string>()); // If wrong input data if (lesSolutionText.Text == "Wrong input system. Check the input" + " data for pattern matching " + "(look at the example).") leSystem.BackColor = Color.FromArgb(0,255, 189, 189); else leSystem.BackColor = Color.FromArgb(160, 247, 247, 255); // Seting up controlls lesSolutionText.Visible = true; }