public void PostRate_FailForbidden()
        {
            // Arrange
            var controller = new NewsItemsController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("Cookie", "sessionString=i81S2p54tJ5LV0F658HCXK2zF57M3L");
            controller.Request.RequestUri = new Uri("https://localhost:44341/api/");
            controller.PostRate(2, 8);

            // Act
            var response = controller.PostRate(2, 8);

            // Assert
            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
        }
        public void PostRate_FailBadRequest()
        {
            // Arrange
            var controller = new NewsItemsController();

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

            // Act
            var response = controller.PostRate(2, 123);

            // Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Exemple #3
0
        public void PostRate_NotFound()
        {
            // Arrange
            var controller = new NewsItemsController();

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

            // Act
            var response = controller.PostRate(-3, 8);

            // Assert
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
        }
        public void PostRate_OK()
        {
            // Arrange
            var controller = new NewsItemsController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("sessionString", "i71S2pE8tJ5LV0F658HCXK2zF57M3L"); // nit: might be a good idea to generate that one prior
            controller.Request.RequestUri = new Uri("https://localhost:44341/api/");

            // Act
            var response = controller.PostRate(2, 8);

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            // nit: might be a good idea to check if that rate changed anything
        }