public async Task GivenAnId_WhenDeleteAsync_ThenReturnTrue()
        {
            var user = UserFactory.AddedUser(_database.DbContext);

            var result = await _repository.DeleteAsync(user.Id);

            result.Should().BeTrue();
        }
        public async Task GivenAnUser_WhenUpdateUserType_ThenReturnUserWithUnchangedType()
        {
            var user        = UserFactory.AddedUser(_database.DbContext);
            var updatedUser = UserFactory.UpdateTypeValidUser(user.Id);

            var result = await _repository.UpdateUser(updatedUser);

            result.Should().BeOfType <User>();
            result.Id.Should().Be(updatedUser.Id);
            result.Type.Should().Be(user.Type);
        }
Exemplo n.º 3
0
        public void GivenEntity_WhenLogin_ThenReturnEntityWithToken()
        {
            var user   = UserFactory.AddedUser(_database.DbContext);
            var entity = new ResponseEntity
            {
                Id = user.Id
            };

            var result = _repository.Login(entity);

            result.Should().NotBeNull();
            result.Id.Should().Be(entity.Id);
            result.Token.Should().NotBeNullOrEmpty();
        }
        public async Task GivenAnUser_WhenUpdateUser_ThenReturnUserUpdated()
        {
            var user        = UserFactory.AddedUser(_database.DbContext);
            var updatedUser = UserFactory.UpdateUsernameAndEmailValidUser(user.Id);

            var result = await _repository.UpdateUser(updatedUser);

            result.Should().BeOfType <User>();
            result.Id.Should().Be(updatedUser.Id);
            result.Username.Should().Be(updatedUser.Username);
            result.Email.Should().BeEquivalentTo(updatedUser.Email);
            result.Location.Should().BeEquivalentTo(user.Location);
            result.TicketsId.Should().HaveCount(user.TicketsId.Count);
        }
        public async Task GivenAnId_WhenGetByIdAsync_ThenReturnAnUser()
        {
            var user = UserFactory.AddedUser(_database.DbContext);

            var result = await _repository.GetByIdAsync(user.Id);

            result.Should().NotBeNull();
            result.Should().BeOfType <User>();
            result.Id.Should().Be(user.Id);
            result.Username.Should().Be(user.Username);
            result.Email.Should().Be(user.Email);
            result.Location.Should().Be(user.Location);
            result.Type.Should().Be(user.Type);
            result.TicketsId[0].Should().Be(user.TicketsId[0]);
        }