public Order DisplayOrderInformation(string file, int orderNumber) { var ops = new OrderOperations(); //string formattedDate = GetOrderDateFromUser(); //int num = GetOrderNumberFromUser(); var response = ops.GetOrder(file, orderNumber); //_currentOrder = response.OrderInfo; if (response.Success) { _currentOrder = response.OrderInfo; PrintOrderInformation(response.OrderInfo); return _currentOrder; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tError occurred!!"); Console.WriteLine(response.Message); Console.WriteLine("\tPress enter to continue..."); log.ErrorMessage = "That was not a valid order UI:DisplayOrdererInfo...."; ops.CallingErrorLogRepository(log.ErrorMessage); Console.ReadLine(); //GetOrderNumberFromUser();//******************** return null; } }
public void GetOrder_ShouldReturn_True_IfOrderExists() { //Arrange var repo = new TestRepository(); string fakeDate = @"DataFiles\TestFiles\Orders_01012020.txt"; OrderOperations ops = new OrderOperations(repo); //Act Response response = ops.GetOrder(fakeDate, 2); //Assert Assert.AreEqual(true, response.Success); }
public void GetOrder_ShouldReturn_False_IfOrder_DoesNotExist() { //Arrange var repo = new TestRepository(); var errorLogRepository = new FakeErrorLogRepository(); string fakeDate = @"DataFiles\TestFiles\Orders_01012020.txt"; OrderOperations ops = new OrderOperations(repo, errorLogRepository); //Act Response response = ops.GetOrder(fakeDate, 5); //Assert Assert.AreEqual(false, response.Success); }
public int DisplayAllAccounts(string file) { Console.Clear(); var ops = new OrderOperations(); //get all orders from the entered file List<Order> allOrdersToDisplay = ops.GetAllOrders(file); Console.WriteLine("\t"); foreach (var a in allOrdersToDisplay) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\t************************"); Console.WriteLine("\tOrder Number: {0}", a.OrderNumber); Console.WriteLine("\t************************"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\tName: {0}", a.LastName.ToUpper()); Console.WriteLine("\tState: {0}", a.State.ToUpper()); } do { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\n PLEASE CH0OSE AN ORDER NUMBER...."); string input = Console.ReadLine(); int OrderNumber; if (int.TryParse(input, out OrderNumber)) { // is this valid order if (ops.GetOrder(file, OrderNumber).Success) { Console.Clear(); return OrderNumber; } } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tThat was not a valid entry...."); log.ErrorMessage = "That was not a valid order number entry UI:DisplayALlAccounts...."; ops.CallingErrorLogRepository(log.ErrorMessage); Console.WriteLine("\tPress enter to continue...."); Console.ReadLine(); } while (true); }