Exemplo n.º 1
0
        public void Hello_Should_ReturnExpectedWelcomeMessage()
        {
            const string welcomeMessage = "TEST";
            const string name           = "Bob";

            var expectedWelcome = $"{welcomeMessage} {name}";

            var mockOptions = new Mock <IOptions <MessagesConfiguration> >();

            mockOptions.Setup(x => x.Value).Returns(new MessagesConfiguration {
                WelcomeMessage = welcomeMessage
            });

            var sut = new SampleController(mockOptions.Object, new NullLogger <SampleController>());

            var actionResult = sut.Hello(name);

            var okResult = actionResult.Result.Should().BeAssignableTo <OkObjectResult>()
                           .Which.Value.Should().BeAssignableTo <HelloOutputModel>()
                           .Which.WelcomeMessage.Should().Be(expectedWelcome);
        }