Exemplo n.º 1
0
        public void setOrderPrices()
        {
            OrderDto order = new OrderDto
            {
                Customer = new CustomerDto {
                    Name = "Test", Surname = "Surname", Email = "*****@*****.**"
                },
                OrderDetails = new List <OrderDetailDto>
                {
                    new OrderDetailDto {
                        PhoneId = 1, PhoneName = "Samsung", Quantity = 1
                    },
                }
            };
            List <OrderDetailResultDto> detailResult = new List <OrderDetailResultDto>
            {
                new OrderDetailResultDto {
                    PhoneId = 1, PhonePrice = 900
                }
            };
            IOrderCW _phoneWorker = new OrderCW();

            var result = _phoneWorker.completeResultInformation(order, detailResult);

            Assert.IsFalse(result.Any(x => x.Quantity == 0 || string.IsNullOrEmpty(x.PhoneName)));
        }
Exemplo n.º 2
0
        public void getPhonePrices()
        {
            var        mock = new Mock <APIHelper>();
            List <int> ids  = new List <int> {
                1, 2
            };
            List <OrderDetailDto> parameter = new List <OrderDetailDto>
            {
                new OrderDetailDto {
                    PhoneId = 1, PhoneName = "Samsung", Quantity = 2
                },
                new OrderDetailDto {
                    PhoneId = 2, PhoneName = "IPhone", Quantity = 1
                },
            };
            OrderDetailResultDto odrd1 = new OrderDetailResultDto {
                PhoneId = 1, PhonePrice = 100
            };
            OrderDetailResultDto odrd2 = new OrderDetailResultDto {
                PhoneId = 2, PhonePrice = 200
            };
            List <OrderDetailResultDto> mockResult = new List <OrderDetailResultDto> {
                odrd1, odrd2
            };

            mock.Setup(m => m.Post <List <OrderDetailResultDto> >("Phones", ids)).Returns(Task.FromResult(mockResult));
            IOrderCW _phoneWorker = new OrderCW(mock.Object);

            var result = _phoneWorker.getPhonePrices(parameter).Result;

            Assert.IsTrue(result.Any());
        }