Exemple #1
0
        public async Task ThenTheUserRepositoryIsCalledToGetAllUsers()
        {
            //Act
            await _getUsersQueryHandler.Handle(new GetUsersQuery());

            //Assert
            _userRepository.Verify(x => x.GetAllUsers(), Times.Once);
        }
Exemple #2
0
        public async Task Should_Have_Return_User_List()
        {
            var handler = new GetUsersQueryHandler(userRepository);
            var result  = await handler.Handle(new GetUsersQuery(), CancellationToken.None);

            Assert.Equal(2, result.Count);
        }
        public async Task ThenItShouldReturnTheUsers()
        {
            // Act
            var actual = await _handler.Handle(_query);

            // Assert
            Assert.AreSame(_users, actual.Users);
            Assert.AreEqual(_users.Length, actual.RecordCount);
        }
        public async Task GetUsersHandler_Should_Get_Users()
        {
            // Arrange...
            var unitOfWork = GetUnitOfWork(out var inMemoryContext);

            InMemoryContextHelper.AddUsersToContext(_fixture, inMemoryContext, 5);
            var mapper        = GetMapper();
            var sut           = new GetUsersQueryHandler(unitOfWork, mapper);
            var getUsersQuery = new GetUsersQuery
            {
                PageNumber = 1,
                PageSize   = 10
            };
            var ct = new CancellationToken();

            // Act...
            await sut.Handle(getUsersQuery, ct);

            // Assert...
            inMemoryContext.Users.Count().Should().Be(5);
        }