public void FullUnitTest() { string inputFile = GetTestFilePath("UTinput.xml"); var testProcess = new ProcessFile(inputFile); StreamWriter log; var logPath = GetTestFilePath("server.log"); if (!File.Exists(logPath)) { log = new StreamWriter(logPath); } else { log = File.AppendText(logPath); } TradeResult tradeResult = testProcess.Run(writeCsv: false, log); Assert.AreEqual(3, tradeResult.TradeValues.Count, "TradeValues list is missing some values."); Assert.AreEqual(new Tuple <int, int, TradeResult.TradeState>(200, 2, TradeResult.TradeState.Pending), tradeResult.TradeValues[0]); Assert.AreEqual(new Tuple <int, int, TradeResult.TradeState>(222, 1, TradeResult.TradeState.Rejected), tradeResult.TradeValues[1]); Assert.AreEqual(new Tuple <int, int, TradeResult.TradeState>(234, 3, TradeResult.TradeState.Accepted), tradeResult.TradeValues[2]); }
static void Main(string[] args) { try { int n1 = int.Parse(Console.ReadLine()); int n2 = int.Parse(Console.ReadLine()); int result = n1 / n2; Console.WriteLine(result); } catch (DivideByZeroException) { Console.WriteLine($"Não é possivel dividir por zero"); } catch (FormatException) { Console.WriteLine($"O numeros devem ser inteiros"); } finally { //Muito usado para fechar arquivos e conexão com banco Console.WriteLine($"Finally"); } Console.WriteLine("Hello World!"); ProcessFile.Run(); }
public void BadFileUnitTest() { string inputFile = GetTestFilePath("inputWithError.xml"); var testProcess = new ProcessFile(inputFile); StreamWriter log; var logPath = GetTestFilePath("BFserver.log"); if (!File.Exists(logPath)) { log = new StreamWriter(logPath); } else { log = File.AppendText(logPath); } TradeResult tradeResult = testProcess.Run(writeCsv: false, log); Assert.IsNull(tradeResult, "TradeValues list should be null since the input file is corrupted."); }