Exemple #1
0
        public void CanParseString()
        {
            //Arrange
            string polynom = "1+2xy=x2+5";
            var target = new MathParserService();

            //Act
            var result = target.Parse(polynom);

            //Accert
            Assert.AreEqual(result, "2xy-x-4=0");
        }
Exemple #2
0
        public void CanOpenBraces()
        {
            //Arrange
            string polynom = "1x-(2x^2-3xy)=2xy";
            var target = new MathParserService();

            //Act
            var result = target.OpenBraces(polynom);

            //Accert
            Assert.AreEqual(result, "1x-2x^2+3xy=2xy");
        }
Exemple #3
0
        public void CanParseArray()
        {
            //Arrange
            string[] polynoms = new string[] { "1+2xy=x2+5", "x2+6=x^2+7", "x2+8=3x^2" };
            var target = new MathParserService();

            //Act
            var result = target.Parse(polynoms);

            //Accert
            Assert.AreEqual(result[0], "2xy-x-4=0");
            Assert.AreEqual(result[1], "-x^2+x-=0");
            Assert.AreEqual(result[2], "-3x^2+x+8=0");
        }
Exemple #4
0
 static void Main(string[] args)
 {
     MathParserService mathParserService = new MathParserService();
     if (args.Length == 0)
     {
         Console.Write("Введите уравнение:");
         string result = mathParserService.Parse(Console.ReadLine());
         Console.WriteLine("Результат:{0}", result);
         Console.Read();
     }
     else
     {
         string filePath = args[0];
         //string filePath = @"C:\Users\Chii\Desktop\QuadraticEquationSimplificator\Test.txt";//args[0];
         Console.WriteLine("Выбран путь к файлу: {0}", filePath);
         RWTextFile.WriteTextFile(mathParserService.Parse(RWTextFile.ReadTextFile(filePath)), filePath);
         //var dummy = Parser.Parse(RWTextFile.ReadTextFile(filePath));
         //Console.WriteLine(String.Join(Environment.NewLine, dummy));
         //Console.ReadLine();
     }
 }