Пример #1
0
        public void ApiController_CreatedAtRoute()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var product = new Product();

            // Act
            var result = controller.CreatedAtRoute("api_route", new { controller = "Products" }, product);

            // Assert
            var created = Assert.IsType <CreatedAtRouteResult>(result);

            Assert.Same(product, created.Value);
            Assert.Equal("api_route", created.RouteName);
            Assert.Equal("Products", created.RouteValues["controller"]);
        }
Пример #2
0
        public void ApiController_CreatedAtRoute_Dictionary()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var product = new Product();
            var values  = new RouteValueDictionary(new { controller = "Products" });

            // Act
            var result = controller.CreatedAtRoute("api_route", values, product);

            // Assert
            var created = Assert.IsType <CreatedAtRouteResult>(result);

            Assert.Same(product, created.Value);
            Assert.Equal("api_route", created.RouteName);
            Assert.Equal("Products", created.RouteValues["controller"]);
            Assert.Equal <KeyValuePair <string, object> >(values, created.RouteValues);
        }
Пример #3
-1
        public void ApiController_CreatedAtRoute_Dictionary()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var product = new Product();
            var values = new RouteValueDictionary(new { controller = "Products" });

            // Act
            var result = controller.CreatedAtRoute("api_route", values, product);

            // Assert
            var created = Assert.IsType<CreatedAtRouteResult>(result);
            Assert.Same(product, created.Value);
            Assert.Equal("api_route", created.RouteName);
            Assert.Equal("Products", created.RouteValues["controller"]);
            Assert.Equal<KeyValuePair<string, object>>(values, created.RouteValues);
        }
Пример #4
-1
        public void ApiController_CreatedAtRoute()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var product = new Product();

            // Act
            var result = controller.CreatedAtRoute("api_route", new { controller = "Products" }, product);

            // Assert
            var created = Assert.IsType<CreatedAtRouteResult>(result);
            Assert.Same(product, created.Value);
            Assert.Equal("api_route", created.RouteName);
            Assert.Equal("Products", created.RouteValues["controller"]);
        }