コード例 #1
0
        public async Task UpdateUser()
        {
            var context = AppDbContextHelper.Create();
            var user    = new User
            {
                Name     = "Jorge",
                LastName = "Martinez",
                Email    = "*****@*****.**",
                IsActive = true
            };

            context.Users.Add(user);
            context.SaveChanges();

            // Arrange
            var service = new UserService(context);
            var userDto = new UserDto
            {
                Id       = 1,
                Name     = "Jorge",
                LastName = "Martinez",
                Email    = "*****@*****.**",
                IsActive = true
            };

            // Act
            var result = await service.UpdateAsync(userDto);

            // Assert
            Assert.NotNull(result);
        }
コード例 #2
0
        public async Task GetAllUsers()
        {
            var context = AppDbContextHelper.Create();

            // Arrange
            var service = new UserService(context);

            // Act
            var result = await service.GetAllAsync();

            // Assert
            Assert.NotNull(result);
        }
コード例 #3
0
        public async Task GetByIdUserDontExistId()
        {
            var context = AppDbContextHelper.Create();

            // Arrange
            var service = new UserService(context);

            // Act
            var result = await service.GetByIdAsync(-1);

            // Assert
            Assert.Null(result);
        }
コード例 #4
0
        public async Task CreateUserInvalidEmail()
        {
            var context = AppDbContextHelper.Create();

            // Arrange
            var service = new UserService(context);
            var user    = new UserDto
            {
                Name     = "Jorge",
                LastName = "Martinez",
                Email    = string.Empty,
                IsActive = true
            };

            // Act
            var result = await service.CreateAsync(user);

            // Assert
            Assert.Null(result);
        }
コード例 #5
0
        public async Task CreateUserRequiredLastName()
        {
            var context = AppDbContextHelper.Create();

            // Arrange
            var service = new UserService(context);
            var user    = new UserDto
            {
                Name     = "Jorge",
                LastName = string.Empty,
                Email    = "*****@*****.**",
                IsActive = true
            };

            // Act
            var result = await service.CreateAsync(user);

            // Assert
            Assert.Null(result);
        }
コード例 #6
0
        public async Task UpdateUserDontExistId()
        {
            var context = AppDbContextHelper.Create();

            // Arrange
            var service = new UserService(context);
            var user    = new UserDto
            {
                Id       = -1,
                Name     = "Jorge",
                LastName = "Martinez",
                Email    = "*****@*****.**",
                IsActive = true
            };

            // Act
            var result = await service.UpdateAsync(user);

            // Assert
            Assert.Null(result);
        }