Esempio n. 1
0
        public void GetAll()
        {
            var returnObj = new List <DeliveryServiceModel>()
            {
                new DeliveryServiceModel(),
                new DeliveryServiceModel()
            };

            this.deliveryServiceAdapter.Setup(x => x.GetAll()).Returns(returnObj);
            var controller = new DeliveryController(deliveryServiceAdapter.Object);
            var output     = controller.GetAll();

            deliveryServiceAdapter.VerifyAll();
            Assert.IsTrue(output.Count == 2);
        }
Esempio n. 2
0
        public async void GetAllDeliveriesTest()
        {
            var controller = new DeliveryController(deliveryService, mapper);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new System.Security.Claims.ClaimsPrincipal()
                }
            };

            var response = await controller.GetAll();

            var okResult = response as OkObjectResult;

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

            var deliveries = okResult.Value as IEnumerable <DeliveryViewModel>;

            Assert.NotEmpty(deliveries);
        }