コード例 #1
0
        public async void GetReturnValidResponseIfDeliveryNotFoundTest()
        {
            var controller = new DeliveryController(deliveryService, mapper);;
            var response   = await controller.Get(-5);

            var notFoundResult = response as NotFoundObjectResult;

            Assert.NotNull(notFoundResult);
            Assert.Equal(404, notFoundResult.StatusCode);
        }
コード例 #2
0
        public async void GetSingleDeliveryTest()
        {
            var delivery = new Delivery
            {
                OrderId      = 10,
                Status       = DeliveryStatus.Approved,
                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);;

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new System.Security.Claims.ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                        new Claim(ClaimTypes.NameIdentifier, "1")
                    }))
                }
            };

            var response1 = await controller.Get(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(delivery.Id, delivery1.Id);
        }
コード例 #3
0
 public void GetOk(string origin, string destination)
 {
     _deliveryController.Get(origin, destination);
 }