Beispiel #1
0
        public async void ApproveDeliveryStatusReturnValidResponseIfDeliveryNotFoundTest()
        {
            var controller = new DeliveryController(deliveryService, mapper);;
            var response   = await controller.ApproveDelivery(-9);

            var notFoundResult = response as NotFoundObjectResult;

            Assert.NotNull(notFoundResult);
            Assert.Equal(404, notFoundResult.StatusCode);
        }
Beispiel #2
0
        public async void ApproveDeliveryTest()
        {
            var delivery = new Delivery
            {
                OrderId      = 10,
                Status       = DeliveryStatus.Created,
                AccessWindow = new AccessWindow
                {
                    StartTime = DateTime.Now,
                    EndTime   = DateTime.Now.AddHours(2)
                },
                Sender = new Partner
                {
                    Name = "Ikea"
                },
                Recipient = new User
                {
                    FirstName = "John",
                    LastName  = "Doe",
                    Email     = "*****@*****.**",
                    Address   = "Test Street, London",
                    Phone     = "0845345"
                }
            };

            dbContext.Add(delivery);
            dbContext.SaveChanges();

            var controller = new DeliveryController(deliveryService, mapper);
            var response1  = await controller.ApproveDelivery(delivery.Id);

            var okResult1 = response1 as OkObjectResult;

            Assert.NotNull(okResult1);
            Assert.Equal(200, okResult1.StatusCode);
            Assert.NotNull(okResult1.Value);

            var delivery1 = okResult1.Value as DeliveryViewModel;

            Assert.Equal(DeliveryStatus.Approved, Enum.Parse <DeliveryStatus>(delivery1.Status, true));
        }
Beispiel #3
0
        public async void UpdateDeliveryStatusCannotSetStatusToApprovedIfNotStatusIsCreatedTest()
        {
            var delivery = new Delivery
            {
                OrderId      = 10,
                Status       = DeliveryStatus.Expired,
                AccessWindow = new AccessWindow
                {
                    StartTime = DateTime.Now,
                    EndTime   = DateTime.Now.AddHours(2)
                },
                Sender = new Partner
                {
                    Name = "Ikea"
                },
                Recipient = new User
                {
                    FirstName = "John",
                    LastName  = "Doe",
                    Email     = "*****@*****.**",
                    Address   = "Test Street, London",
                    Phone     = "0845345"
                }
            };

            dbContext.Add(delivery);
            dbContext.SaveChanges();
            var controller = new DeliveryController(deliveryService, mapper);;
            var response   = await controller.ApproveDelivery(delivery.Id);

            var badResult = response as BadRequestObjectResult;

            Assert.NotNull(badResult);
            Assert.Equal(400, badResult.StatusCode);
            Assert.NotNull(badResult.Value);
        }