public void TestAddOrder() { Order order1 = new Order(); Order order2 = new Order(); Order order3 = new Order(); AddOrderCommand addCommand1 = new AddOrderCommand(order1); AddOrderCommand addCommand2 = new AddOrderCommand(order2); AddOrderCommand addCommand3 = new AddOrderCommand(order3); CommandService service = new CommandService(); service.ExecuteCommand(addCommand1); service.ExecuteCommand(addCommand2); service.ExecuteCommand(addCommand3); ICommand command = service.Undo(); Order deletedOrder = command.CommandParams[0] as Order; Assert.That(order3.OrderId,Is.EqualTo(deletedOrder.OrderId)); Repositiory.Close(Common.Util.GetContextId()); }
public void TestDeleteCustomerAndUndo() { OrderService.QueryService.CustomerQueryService service = new OrderService.QueryService.CustomerQueryService(); var customers = service.All(); long count = service.Count(); Customer customer = customers.ElementAt(new Random().Next(0, (int)count - 1)); RemoveCustomerCommand command = new RemoveCustomerCommand(customer); CommandService commandService = new CommandService(); commandService.ExecuteCommand(command); commandService.Undo(); long countAfter = service.Count(); Assert.That(count, Is.EqualTo(countAfter)); Repositiory.Close(Common.Util.GetContextId()); }
public void TestDeleteOrderAndUndo() { OrderService.OrderService service = new OrderService.OrderService(); long numOrders = service.GetOrderCount(); var allOrders = service.GetAllOrders(); Order order = allOrders.ElementAt(new Random().Next(0, (int)numOrders - 1)); RemoveOrderCommand remCommand = new RemoveOrderCommand(order); CommandService commandService = new CommandService(); commandService.ExecuteCommand(remCommand); commandService.UndoCommand(remCommand); long numOrdersAfter = service.GetOrderCount(); Assert.That(numOrdersAfter, Is.EqualTo(numOrders)); Repositiory.Close(Common.Util.GetContextId()); }