Пример #1
0
        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 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);
        }
Пример #3
0
        public static OrganizationController GetOrganizationController(string name)
        {
            // var logger = LoggingHelper.GetLogger<EmployeeController>();
            var identityClient = new MockedRothschildHouseIdentityClient();

            var userInfo = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service  = ServiceMocker.GetOrganizationService(userInfo, name);

            return(new OrganizationController(identityClient, service));
        }
        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);
        }
Пример #7
0
        public async Task TestGetOrdersAsync()
        {
            // Arrange
            var userInfo   = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service    = ServiceMocker.GetSalesService(userInfo, nameof(TestGetOrdersAsync));
            var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service);

            // Act
            var response = await controller.GetOrdersAsync() as ObjectResult;

            var value = response.Value as IPagedResponse <OrderInfo>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
        }
Пример #8
0
        public async Task TestGetProductsTestAsync()
        {
            // Arrange
            var userInfo   = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service    = ServiceMocker.GetWarehouseService(userInfo, nameof(TestGetProductsTestAsync));
            var controller = new WarehouseController(LoggingHelper.GetLogger <WarehouseController>(), service);

            // Act
            var response = await controller.GetProductsAsync() as ObjectResult;

            var value = response.Value as IPagedResponse <Product>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Count() > 0);
        }
Пример #9
0
        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);
        }
Пример #10
0
        public async Task TestGetOrdersByCurrencyAsync()
        {
            // Arrange
            var userInfo   = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service    = ServiceMocker.GetSalesService(userInfo, nameof(TestGetOrdersByCurrencyAsync));
            var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service);
            var currencyID = "USD";

            // Act
            var response = await controller.GetOrdersAsync(currencyID : currencyID) as ObjectResult;

            var value = response.Value as IPagedResponse <OrderInfo>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Count() > 0);
            Assert.True(value.Model.Count(item => item.CurrencyID == currencyID) == value.Model.Count());
        }
Пример #11
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());
        }