public async Task TestPostOrderAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestPostOrderAsync), true); var identityClient = new MockedRothschildHouseIdentityClient(); var paymentClient = new MockedRothschildHousePaymentClient(); var controller = new SalesController(null, identityClient, paymentClient, service); var request = new PostOrderRequest { ID = 2, CustomerID = 1, PaymentMethodID = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"), CurrencyID = "USD", Comments = "Order from unit tests", Details = new List <OrderDetailRequest> { new OrderDetailRequest { ID = 2, ProductID = 1, Quantity = 1 } } }; // Act var response = await controller.PostOrderAsync(request) as ObjectResult; var value = response.Value as ISingleResponse <OrderHeader>; // Assert Assert.False(value.DidError); Assert.True(value.Model.ID.HasValue); }
public async Task TestCreateOrderAsync() { // Arrange var logger = LoggingHelper.GetLogger <SalesController>(); var service = ServiceMocker.GetSalesService(nameof(TestCreateOrderAsync)); var controller = new SalesController(logger, service); var model = new OrderHeaderRequest { CustomerID = 1, PaymentMethodID = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"), Comments = "Order from unit tests", CreationUser = "******", CreationDateTime = DateTime.Now, Details = new List <OrderDetailRequest> { new OrderDetailRequest { 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 <OrderHeader>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.OrderHeaderID.HasValue); }
public async Task TestPostOrderAsync() { // Arrange var dbContext = DbContextMocker.GetStoreDbContext(nameof(TestPostOrderAsync)); var service = ServiceMocker.GetSalesService(dbContext); var controller = new SalesController(service, null); var request = new PlaceOrderRequest { Details = new List <PlaceOrderDetailRequest> { new PlaceOrderDetailRequest { ProductID = 1000, Quantity = 1 } } }; controller.MockControllerContext(); // Act var response = await controller.PostOrderAsync(request) as ObjectResult; var value = response.Value as IResponse; service.Dispose(); // Assert Assert.False(value?.DidError); }
public async Task TestCreateOrderAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestCreateOrderAsync)); var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service); var request = new Requests.CreateOrderRequest { CustomerID = 1, PaymentMethodID = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"), CurrencyID = "USD", Comments = "Order from unit tests", Details = new List <OrderDetailRequest> { new OrderDetailRequest { ProductID = 1, Quantity = 1 } } }; // Act var response = await controller.CreateOrderAsync(request) as ObjectResult; var value = response.Value as ISingleResponse <OrderHeader>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.OrderHeaderID.HasValue); }
public async Task TestGetCreateOrderRequestAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestGetCreateOrderRequestAsync), true); var controller = new SalesController(null, null, null, service); // Act var response = await controller.GetPostOrderModelAsync() as ObjectResult; var value = response.Value as ISingleResponse <CreateOrderRequest>; // Assert Assert.False(value.DidError); }
public async Task TestCloneOrderAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestCloneOrderAsync), true); var controller = new SalesController(null, null, null, service); var id = 1; // Act var response = await controller.CloneOrderAsync(id) as ObjectResult; var value = response.Value as ISingleResponse <OrderHeader>; // Assert Assert.False(value.DidError); }
public async Task TestSearchOrdersAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestSearchOrdersAsync), true); var controller = new SalesController(null, null, null, service); var request = new GetOrdersRequest(); // Act var response = await controller.GetOrdersAsync(request) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; // Assert Assert.False(value.DidError); }
public async Task TestGetOrdersAsync() { // Arrange var logger = LoggingHelper.GetLogger <SalesController>(); var service = ServiceMocker.GetSalesService(nameof(TestGetOrdersAsync)); var controller = new SalesController(logger, service); // Act var response = await controller.GetOrdersAsync() as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; service.Dispose(); // Assert Assert.False(value.DidError); }
public async Task TestGetNonExistingOrderAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestGetNonExistingOrderAsync)); var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service); var id = 0; // Act var response = await controller.GetOrderAsync(id) as ObjectResult; var value = response.Value as ISingleResponse <OrderHeader>; service.Dispose(); // Assert Assert.False(value.DidError); }
public async Task TestGetOrdersByEmployeeAsync() { // Arrange var logger = LoggingHelper.GetLogger <SalesController>(); var service = ServiceMocker.GetSalesService(nameof(TestGetOrdersByEmployeeAsync)); var controller = new SalesController(logger, service); var employeeID = 1; // Act var response = await controller.GetOrdersAsync(employeeID : employeeID) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Count(item => item.EmployeeID == employeeID) == value.Model.Count()); }
public async Task TestGetCreateOrderRequestAsync() { // Arrange var logger = LoggingHelper.GetLogger <SalesController>(); var service = ServiceMocker.GetSalesService(nameof(TestGetCreateOrderRequestAsync)); var controller = new SalesController(logger, service); // Act var response = await controller.GetCreateOrderRequestAsync() as ObjectResult; var value = response.Value as ISingleResponse <CreateOrderRequest>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Products.Count() > 0); Assert.True(value.Model.Customers.Count() > 0); }
public async Task TestGetOrdersByCustomerAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestGetOrdersByCustomerAsync)); var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service); var customerID = 1; // Act var response = await controller.GetOrdersAsync(customerID : customerID) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Count(item => item.CustomerID == customerID) == value.Model.Count()); }
public async Task TestGetCreateOrderRequestAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(TestGetCreateOrderRequestAsync)); var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service); // Act var response = await controller.GetCreateOrderRequestAsync() as ObjectResult; var value = response.Value as ISingleResponse <Core.BusinessLayer.Requests.CreateOrderRequest>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.Products.Count() > 0); Assert.True(value.Model.Customers.Count() > 0); }
public async Task GetOrdersByEmployeeAsync() { // Arrange var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo(); var service = ServiceMocker.GetSalesService(userInfo, nameof(GetOrdersByEmployeeAsync), true); var controller = new SalesController(null, null, null, service); var request = new GetOrdersRequest { EmployeeID = 1 }; // Act var response = await controller.GetOrdersAsync(request) as ObjectResult; var value = response.Value as IPagedResponse <OrderInfo>; // Assert Assert.False(value.DidError); Assert.True(value.Model.Count(item => item.EmployeeID == request.EmployeeID) == value.Model.Count()); }