Ejemplo n.º 1
0
        public void Get_Random_WhenCalled_ReturnsOkResult()
        {
            // Arrange
            var expected = new Greeting
            {
                Id      = Guid.NewGuid(),
                Name    = "Hello ESDC",
                Message = "Test 1",
            };

            this.mockGreetingService.Setup(x => x.GetRandom()).Returns(() => expected);

            // Act
            var controller = new GreetingController(this.mockGreetingService.Object);
            var result     = controller.Random().Result;

            // Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var greeting = okResult.Value.Should().BeAssignableTo <Greeting>().Subject;

            greeting.Id.Should().Be(expected.Id);
            greeting.Name.Should().Be("Hello ESDC");
        }