Exemplo n.º 1
0
        public void GetGreetings()
        {
            // Arrange
            CitiesController controller = new CitiesController();

            // Act
            IHttpActionResult result = controller.GetGreetings(_CITY_GUID, _USER_GUID);
            var contentResult        = result as OkNegotiatedContentResult <getUserGreetingsResponse>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsNotNull(contentResult.Content.greetings);
            Assert.IsInstanceOfType(contentResult.Content, typeof(getUserGreetingsResponse));
            Assert.AreNotEqual(contentResult.Content.greetings.Count, 0);

            //***Test Invalid CityGuid Request***
            // Act
            IHttpActionResult resultCityInvalidGuid = controller.GetGreetings("invalid", _USER_GUID);

            // Assert
            Assert.IsNotNull(resultCityInvalidGuid);
            Assert.IsInstanceOfType(resultCityInvalidGuid, typeof(BadRequestErrorMessageResult));
            //*************************

            //***Test Invalid UserGuid Request***
            // Act
            IHttpActionResult resultInvalidUserGuid = controller.GetGreetings(_CITY_GUID, "invalid");

            // Assert
            Assert.IsNotNull(resultInvalidUserGuid);
            Assert.IsInstanceOfType(resultInvalidUserGuid, typeof(BadRequestErrorMessageResult));
            //*************************
        }