Beispiel #1
0
        public void GetFizzBuzzText_ReturnsFizzBuzzTextGeneratedFromService()
        {
            //Arrange
            //"Mock the service so that it always returns some (randomly generated) string"
            var expectedText = Guid.NewGuid().ToString();

            _serviceMock.Setup(s => s.GenerateFizzBuzzText(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(expectedText);

            //Act
            var result = _controller.GetFizzBuzzText(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()) as OkNegotiatedContentResult <string>;

            //Assert
            //TODO: assert that the correct IHttpActionResult is returned
            //TODO: assert that the FizzBuzzService was used correctly
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Content, Is.EqualTo(expectedText));
            _serviceMock.Verify(s => s.GenerateFizzBuzzText(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()), Times.Once);
        }