Exemple #1
0
        public async Task EmployerController_WhenDataIsValid_MethodGetMustReturnAllEmployer()
        {
            // Arrange
            var employerController = new EmployerController(_logger.Object, _notificationMessages.Object);
            Mock <IGetEmployerUseCaseAsync> useCase = new Mock <IGetEmployerUseCaseAsync>();
            var response = GetListEmployer();

            useCase.Setup(x => x.RunAsync()).ReturnsAsync(response);
            var result = await employerController.GetAll(useCase.Object);

            // Act
            var objectResult   = result.Should().BeOfType <OkObjectResult>().Subject;
            var objectResponse = objectResult.Value.Should().BeAssignableTo <IEnumerable <EmployeeEntity> >().Subject;

            // Assert
            Assert.NotNull(objectResponse);
            Assert.Collection(objectResponse,
                              item => Assert.Equal("TI", item.Name),
                              item => Assert.Equal("Business", item.Name),
                              item => Assert.Equal("Management", item.Name),
                              item => Assert.Equal("Marketing", item.Name));
        }