示例#1
0
        public void GetCoursesByUserTest()
        {
            Mock <IUserProfile> userProfile = new Mock <IUserProfile>(MockBehavior.Strict);

            userProfile
            .Setup(exuser => exuser.GetCoursesByUser(It.IsIn(users.Select(u => u.Email))))
            .Returns(courses);
            Mock <IConverterToDTO> converter = new Mock <IConverterToDTO>(MockBehavior.Loose);

            converter
            .Setup(c => c.ConvertToCourseListDTO(It.IsIn <IEnumerable <Course> >(courses)))
            .Returns(new List <CourseDTO>());
            var sut = new UserProfileBll(
                userProfile.Object,
                converter.Object);
            var expected = users[0];
            var actual   = sut.GetCoursesByUser(expected.Email);

            userProfile.Verify(
                up => up.GetCoursesByUser(expected.Email), Times.Once);
            converter.Verify(
                c => c.ConvertToCourseListDTO(
                    It.IsAny <IEnumerable <Course> >()),
                Times.Once);
        }
示例#2
0
        public void GetUserByEmailTest()
        {
            Mock <IUserProfile> userProfile = new Mock <IUserProfile>(MockBehavior.Strict);

            userProfile
            .Setup(exuser => exuser.GetUserByEmail(It.IsIn(users.Select(u => u.Email))))
            .Returns(users[0]);
            Mock <IConverterToDTO> converter = new Mock <IConverterToDTO>(MockBehavior.Loose);

            converter
            .Setup(c => c.ConvertToUserDTO(It.IsIn <User>(users)))
            .Returns(new UserDTO());
            var sut = new UserProfileBll(
                userProfile.Object,
                converter.Object);
            var expected = users[0];
            var actual   = sut.GetUserByEmail(expected.Email);

            userProfile.Verify(
                up => up.GetUserByEmail(expected.Email), Times.Once);
            converter.Verify(
                c => c.ConvertToUserDTO(
                    It.IsAny <User>()),
                Times.Once);
        }
示例#3
0
        public void UpdateUserProfileEmailTest()
        {
            Mock <IUserProfile> userProfile = new Mock <IUserProfile>(MockBehavior.Strict);

            userProfile
            .Setup(exuser =>
                   exuser.UpdateUserProfileEmail(
                       It.IsIn(users.Select(u => u.Id)),
                       It.IsIn(users.Select(u => u.Email))))
            .Returns(updated);
            Mock <IConverterToDTO> converter = new Mock <IConverterToDTO>(MockBehavior.Strict);

            converter
            .Setup(c => c.ConvertToUserDTO(It.IsIn <User>(users)))
            .Returns(new UserDTO());
            var sut         = new UserProfileBll(userProfile.Object);
            var userCurrent = users[0];
            var userUpdate  = users[1];
            var actual      = sut.UpdateUserProfileEmail(userCurrent.Id, userUpdate.Email);

            Assert.AreEqual(updated, actual);

            userProfile.Verify(
                up => up.UpdateUserProfileEmail(userCurrent.Id, userUpdate.Email), Times.Once);
        }