public void ShouldFailIfUserDoesNotExists()
        {
            var dbContext  = InfrastructureFactory.GetInMemoryContext(nameof(ShouldFailIfUserDoesNotExists));
            var unitOfWork = InfrastructureFactory.GetEfUnitOfWork(dbContext);
            var handler    = new GetUserCommandHandler(unitOfWork);

            Assert.ThrowsAsync <UserNotFoundException>(() => handler.Handle(new GetUserCommand("johndoe"), default));
        }
        public async Task ShouldReturnUser()
        {
            var dbContext  = InfrastructureFactory.GetInMemoryContext(nameof(ShouldReturnUser));
            var unitOfWork = InfrastructureFactory.GetEfUnitOfWork(dbContext);
            await unitOfWork.AddAndSaveAsync(EntityFactory.GetUser("johndoe", "Pass@123"));

            var handler = new GetUserCommandHandler(unitOfWork);

            var user = await handler.Handle(new GetUserCommand("johndoe"), default);

            Assert.NotNull(user);
        }
        public async Task GetUserCommandHandlerShouldReturnUserObject()
        {
            var user = new User()
            {
                Password = "******",
                Username = "******"
            };

            var userCommand = new GetUserCommand(user);

            var listUser = new List <User> {
                user
            };

            var handler = new GetUserCommandHandler(_userRepositoryMock.Object);

            _userRepositoryMock.Setup(a => a.Search(a => a.Username == userCommand.User.Username && a.Password == userCommand.User.Password)).ReturnsAsync(listUser);

            var result = await handler.Handle(userCommand, new CancellationToken());

            result.Should().BeOfType <User>();
        }