Пример #1
0
        public void GetById_WhenCalledNotExistUser_ShouldThrowObjectNotFoundExcepiton()
        {
            // Arrange
            var userId      = Guid.Empty;
            var mockUserDal = new MockUserDal().MockGet(null);
            var sut         = new UserManager(mockUserDal.Object);

            // Act & Assert
            Assert.Throws <ObjectNotFoundException>(() => sut.GetById(userId));
        }
Пример #2
0
        public void GetByEmail_WhenCalledNotExistUser_ShouldThrowObjectNotFoundExcepiton()
        {
            // Arrange
            var email       = "*****@*****.**";
            var mockUserDal = new MockUserDal().MockGet(null);
            var sut         = new UserManager(mockUserDal.Object);

            // Act & Assert
            Assert.Throws <ObjectNotFoundException>(() => sut.GetByEmail(email));
        }
Пример #3
0
        public void GetByUsername_WhenCalledNotExistUser_ShouldThrowObjectNotFoundExcepiton()
        {
            // Arrange
            var username    = "******";
            var mockUserDal = new MockUserDal().MockGet(null);
            var sut         = new UserManager(mockUserDal.Object);

            // Act & Assert
            Assert.Throws <ObjectNotFoundException>(() => sut.GetByUsername(username));
        }
Пример #4
0
        public void GetList_WhenCalledAll_ShouldReturnUsers()
        {
            // Arrange
            var mockUserDal = new MockUserDal().MockGetDetailList(new List <UserForDetailDto>());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetList();

            // Assert
            Assert.NotNull(result.Data);
        }
Пример #5
0
        public void GetDetail_WhenCalledUserDetail_ShouldReturnUserDto()
        {
            // Arrange
            var userId      = Guid.NewGuid();
            var mockUserDal = new MockUserDal().MockGetDetail(new UserForDetailDto()).MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetDetail(userId);

            // Assert
            Assert.NotNull(result.Data);
        }
Пример #6
0
        public void GetByEmail_WhenCalledWithEmail_ShouldReturnUser()
        {
            // Arrange
            var email       = "*****@*****.**";
            var mockUserDal = new MockUserDal().MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetByEmail(email);

            // Assert
            Assert.NotNull(result.Data);
        }
Пример #7
0
        public void GetByUsername_WhenCalledWithUsername_ShouldReturnUser()
        {
            // Arrange
            var username    = "******";
            var mockUserDal = new MockUserDal().MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetByUsername(username);

            // Assert
            Assert.NotNull(result.Data);
        }
Пример #8
0
        public void GetUserByEmailForLogin_WhenCalledUserForLogin_ShouldReturnUser()
        {
            // Arrange
            var email       = "*****@*****.**";
            var mockUserDal = new MockUserDal().MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetUserByEmailForLogin(email);

            // Assert
            Assert.NotNull(result);
        }
Пример #9
0
        public void GetClaimsForLogin_WhenCalledClaimsForLogin_ShouldReturnClaimNameArray()
        {
            // Arrange
            var user        = new User();
            var mockUserDal = new MockUserDal().MockGetClaims(Array.Empty <string>());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetClaimsForLogin(user);

            // Assert
            Assert.NotNull(result);
        }
Пример #10
0
        public void Delete_WhenDeletedUser_ShouldUpdateEnableStatus()
        {
            // Arrange
            var userId      = Guid.NewGuid();
            var mockUserDal = new MockUserDal().MockUpdate().MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            sut.Delete(userId);

            // Assert
            mockUserDal.VerifyUpdate(Times.Once());
        }
Пример #11
0
        public void Add_WhenAddedNewUser_ShouldAddAndReturnId()
        {
            // Arrange
            var user        = new User();
            var mockUserDal = new MockUserDal().MockAdd(user);
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.Add(user);

            // Assert
            Assert.Equal(new Guid(), result);
        }
Пример #12
0
        public void GetListByDepartmentId_WhenCalledWithDepartmentId_ShouldReturnUsers()
        {
            // Arrange
            int departmentId = 1;
            var mockUserDal  = new MockUserDal().MockGetList(new List <User>());
            var sut          = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetListByDepartmentId(departmentId);

            // Assert
            Assert.NotNull(result);
        }
Пример #13
0
        public void GetDebits_WhenCalledDebits_ShouldReturnDebitDtos()
        {
            // Arrange
            var userId      = Guid.NewGuid();
            var mockUserDal = new MockUserDal().MockGetDebits(new List <DebitForFixtureDetailDto>()).MockGet(new User());
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.GetDebits(userId);

            // Assert
            Assert.NotNull(result.Data);
        }
Пример #14
0
        public void IsAlreadyExistsUsername_WhenCalledUsernameExists_ShouldReturnExistStatus()
        {
            // Arrange
            var existStatus = false;
            var username    = "******";
            var mockUserDal = new MockUserDal().MockAny(existStatus);
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.IsAlreadyExistsUsername(username);

            // Assert
            Assert.False(result);
        }
Пример #15
0
        public void IsAlreadyExistsEmail_WhenCalledEmailExists_ShouldReturnExistStatus()
        {
            // Arrange
            var existStatus = true;
            var email       = "*****@*****.**";
            var mockUserDal = new MockUserDal().MockAny(existStatus);
            var sut         = new UserManager(mockUserDal.Object);

            // Act
            var result = sut.IsAlreadyExistsEmail(email);

            // Assert
            Assert.True(result);
        }