Example #1
0
        public void PostNewsItem_BadRequest()
        {
            // Arrange
            var controller = new NewsItemsController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.ModelState.AddModelError("Body", "The Body field is required.");

            // Act
            var response = controller.PostNewsItem(new XsollaSummerSchoolTest.NewsItem {
                Headline = "Test post", Category = "Test"
            });
            var result = response as InvalidModelStateResult;

            // Assert
            Assert.IsNotNull(result);
        }
Example #2
0
        public void PostNewsItem_CreatedAtRoute()
        {
            // Arrange
            var controller = new NewsItemsController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            var response = controller.PostNewsItem(new XsollaSummerSchoolTest.NewsItem {
                Headline = "Test post", Body = "Test post", Category = "Test"
            });
            var result = response as CreatedAtRouteNegotiatedContentResult <NewsItemSend>;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("DefaultApi", result.RouteName);
            Assert.IsNotNull(result.RouteValues["id"]);
        }