예제 #1
0
        public void ChangeProfile_ExistingIDSameEMail_UpdatedProfileHasValidData(int userID, string eMail)
        {
            var testDatabaseContext = DbContextFactory.Create();

            var timeProviderMock = new Mock <ITimeProvider>();

            timeProviderMock.Setup(p => p.Now()).Returns(new DateTime(2016, 1, 1));

            var changeProfileDTO = new ChangeProfileDTO
            {
                EMail  = eMail,
                City   = "Test city",
                About  = "Something about me",
                Footer = "Ultra-rare funny footer"
            };

            var profileService = new ProfileService(testDatabaseContext, timeProviderMock.Object);

            profileService.ChangeProfile(userID, changeProfileDTO);

            var updatedProfile = profileService.GetProfileByUserID(userID);

            Assert.Equal(changeProfileDTO.EMail, updatedProfile.EMail);
            Assert.Equal(changeProfileDTO.City, updatedProfile.City);
            Assert.Equal(changeProfileDTO.About, updatedProfile.About);
            Assert.Equal(changeProfileDTO.Footer, updatedProfile.Footer);
        }
예제 #2
0
        public void ChangeProfile_ExistingIDExistingEMail_ThrowsEMailAlreadyExistsException(int userID, string eMail)
        {
            var testDatabaseContext = DbContextFactory.Create();

            var timeProviderMock = new Mock <ITimeProvider>();

            timeProviderMock.Setup(p => p.Now()).Returns(new DateTime(2016, 1, 1));

            var changeProfileDTO = new ChangeProfileDTO
            {
                EMail  = eMail,
                City   = "Test city",
                About  = "Something about me",
                Footer = "Ultra-rare funny footer"
            };

            var profileService = new ProfileService(testDatabaseContext, timeProviderMock.Object);

            var exception = Record.Exception(() => profileService.ChangeProfile(userID, changeProfileDTO));

            Assert.IsType <EMailAlreadyExistsException>(exception);
        }