Esempio n. 1
0
        public void GetHello_ReturnsExpectedResult()
        {
            // Arrange
            var mockMessageServiceReturn = "Hello World";
            var mockService = new Mock <IMessageService>();

            mockService.Setup(svc => svc.GetMessage())
            .Returns(mockMessageServiceReturn);

            var controller = new DemoController(mockService.Object);

            // Act
            var result   = controller.GetHello();
            var okResult = result as OkObjectResult;

            // Assert
            okResult.Should().NotBe(null);
            okResult?.StatusCode.Should().Be(200);
            okResult?.Value.Should().Be("Hello World");
        }