public async Task TestCreateOrderAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(nameof(TestCreateOrderAsync)); var controller = new SalesController(logger, salesService); var model = new OrderRequestModel { CustomerID = 1, PaymentMethodID = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"), Comments = "Order from unit tests", CreationUser = "******", CreationDateTime = DateTime.Now, Details = new List <OrderDetailRequestModel> { new OrderDetailRequestModel { ProductID = 1, ProductName = "The King of Fighters XIV", Quantity = 1, } } }; // Act var response = await controller.CreateOrderAsync(model) as ObjectResult; var value = response.Value as ISingleResponse <Order>; controller.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.OrderID.HasValue); }
public async Task TestGetOrdersAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(nameof(TestGetOrdersAsync)); var controller = new SalesController(logger, salesService); // Act var response = await controller.GetOrdersAsync() as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; controller.Dispose(); // Assert Assert.False(value.DidError); }
public async Task TestGetOrderAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(); var id = 1; using (var controller = new SalesController(logger, salesService)) { // Act var response = await controller.GetOrderAsync(id) as ObjectResult; var value = response.Value as ISingleResponse <Order>; // Assert Assert.False(value.DidError); } }
public async Task TestGetCreateOrderRequestAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(); using (var controller = new SalesController(logger, salesService)) { // Act var response = await controller.GetCreateOrderRequestAsync() as ObjectResult; var value = response.Value as ISingleResponse <CreateOrderRequest>; // Assert Assert.False(value.DidError); Assert.True(value.Model.Products.Count() >= 0); } }
public async Task TestGetOrdersByEmployeeAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(nameof(TestGetOrdersByEmployeeAsync)); var controller = new SalesController(logger, salesService); var employeeID = 1; // Act var response = await controller.GetOrdersAsync(employeeID : employeeID) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; controller.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Where(item => item.EmployeeID == employeeID).Count() == value.Model.Count()); }
public async Task TestGetOrdersByCustomerAsync() { // Arrange var logger = LogHelper.GetLogger <SalesController>(); var salesService = ServiceMocker.GetSalesService(); var customerID = 1; using (var controller = new SalesController(logger, salesService)) { // Act var response = await controller.GetOrdersAsync(customerID : customerID) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; // Assert Assert.False(value.DidError); Assert.True(value.Model.Where(item => item.CustomerID == customerID).Count() == value.Model.Count()); } }