예제 #1
0
        public async Task GetAllUser_WhenUsersAreInDatabase_ShouldReturnUsers(int users)
        {
            // Arrange
            var unitUnderTest         = this.CreateGetAllUserUseCase();
            GetAllUserRequest message = new GetAllUserRequest();
            var entities = new Faker <UserEntity>()
                           .CustomInstantiator(f => new UserEntity(f.Person.FirstName, f.Person.LastName, f.Person.UserName, f.Person.UserName))
                           .RuleFor(u => u.Email, (f, u) => f.Person.Email)
                           .Generate(users);

            subUserRepository.ListAll().Returns(entities);

            IOutputPort <GetAllUserResponse> outputPort =
                Substitute.For <IOutputPort <GetAllUserResponse> >();

            // Act
            bool result = await unitUnderTest.Handle(
                message,
                outputPort);

            // Assert
            Assert.True(result);
            outputPort.Received(1).Handle(
                Arg.Is <GetAllUserResponse>(x => x.Users.Count == users));
        }