示例#1
0
        public void UpdateUserById()
        {
            // Arrange
            var id         = Guid.NewGuid();
            var updateUser = new Contracts.UserUpdate()
            {
                Email     = "*****@*****.**",
                FirstName = "Iam",
                LastName  = "Different",
                Password  = "******"
            };
            var user = new Database.User()
            {
                Id        = id,
                Email     = "*****@*****.**",
                FirstName = "Unit",
                LastName  = "Test",
                Role      = Database.Role.Trader
            };

            user.UpdatePassword("Whatever");
            _dbContext.Add(user);
            _dbContext.SaveChanges();

            // Act
            var updatedUser = _userService.UpdateUserById(id, updateUser);

            // Assert
            Assert.Equal(updateUser.Email, updatedUser.Email);
            Assert.Equal(updateUser.FirstName, updatedUser.FirstName);
            Assert.Equal(updateUser.LastName, updatedUser.LastName);
        }
示例#2
0
        public void UpdateUserById_NotFound()
        {
            // Arrange
            var id         = Guid.NewGuid();
            var updateUser = new Contracts.UserUpdate()
            {
                Email     = "*****@*****.**",
                FirstName = "Iam",
                LastName  = "Different",
                Password  = "******"
            };

            // Act
            // Assert
            var exception = Assert.Throws <ProblemDetailsException>(() => _userService.UpdateUserById(id, updateUser));

            Assert.Equal(HttpStatusCode.NotFound, exception.Status);
        }