using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections;
using System.Diagnostics;
using System.IO;
namespace WpfApplication5
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
ProcessStartInfo a = new ProcessStartInfo();
TextWriter tw;
public MainWindow()
{
InitializeComponent();
a.FileName = "Test.exe";
createTable();
}
public void createTable()
{
tw = new StreamWriter("res.txt");
test("1 2 3 4", "Действительных корней нет!");
test("С 0 3 4", "Первый аргумент не число");
test("5 с 3 4", "Второй аргумент не число!");
test("5 4 C 4", "Третий аргумент не число!");
test("0 4 4 0", "Не квадратное уравнение");
test("5 1 7 0", "Деление на ноль");
test("1 6 9 0", "x1= -3");
tw.Close();
}
public void test(string args,string res)
{
a.Arguments = args;
Process.Start(a);
System.Threading.Thread.Sleep(50);
string ass = readFromTxt();
Write(args + " ожидаемый результат " + res + " полученый результат " + ass + res.Equals(readFromTxt()));
}
public string readFromTxt()
{
try
{
TextReader tr = new StreamReader("test.txt");
string res = tr.ReadToEnd();
tr.Close();
return res;
}
catch(Exception e)
{
return "exception";
}
}
public void Write(string res)
{
tw.WriteLine(res);
}
}
}