Exemplo n.º 1
0
        public void ReturnOkNegotiatedContentResult()
        {
            // Arrange
            string entity       = "Orders";
            var    allCustomers = new List <CustomerModel>()
            {
                new CustomerModel()
                {
                    ContactName = "batka",
                    OrdersCount = 5,
                },
                new CustomerModel()
                {
                    ContactName = "golqma batka",
                    OrdersCount = 15,
                }
            };
            var service = new Mock <ICustomerService>();

            service.Setup(x => x.GetAllIncludeChildEntity(entity)).Returns(allCustomers);
            CustomersController controller = new CustomersController(service.Object);

            // Act
            var result = controller.Customers() as OkNegotiatedContentResult <List <CustomerModel> >;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(allCustomers[0].OrdersCount, result.Content[0].OrdersCount);
            Assert.AreEqual(allCustomers[0].ContactName, result.Content[0].ContactName);
            Assert.AreEqual(allCustomers[1].OrdersCount, result.Content[1].OrdersCount);
            Assert.AreEqual(allCustomers[1].ContactName, result.Content[1].ContactName);
        }
Exemplo n.º 2
0
        public void ReturnNoContentStatusCode()
        {
            // Arrange
            var service = new Mock <ICustomerService>();
            CustomersController controller = new CustomersController(service.Object);

            // Act
            var result = controller.Customers() as StatusCodeResult;

            // Assert
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
Exemplo n.º 3
0
        public void NotBeNull()
        {
            // Arrange
            var service = new Mock <ICustomerService>();
            CustomersController controller = new CustomersController(service.Object);

            // Act
            IHttpActionResult result = controller.Customers() as IHttpActionResult;

            // Assert
            Assert.IsNotNull(result);
        }