Ejemplo n.º 1
0
            public void DoesNotChangeConfirmationTokenButUserHasPendingEmailChange()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", EmailConfirmationToken = "pending-token"
                };
                var service = new TestableUserService();

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Equal("pending-token", user.EmailConfirmationToken);
            }
Ejemplo n.º 2
0
            public void DoesNotSetConfirmationTokenWhenEmailAddressNotChanged()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Null(user.EmailConfirmationToken);
            }
Ejemplo n.º 3
0
            public void DoesNotSetConfirmationTokenWhenEmailAddressNotChanged()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                service.MockCrypto
                .Setup(c => c.GenerateToken())
                .Returns("token");

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Null(user.EmailConfirmationToken);
            }
Ejemplo n.º 4
0
            public void SavesEmailAllowedSetting()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", EmailAllowed = true
                };
                var service = new TestableUserService();

                service.MockUserRepository
                .Setup(r => r.GetAll())
                .Returns(new[] { user }.AsQueryable());

                service.UpdateProfile(user, "*****@*****.**", false);

                Assert.Equal(false, user.EmailAllowed);
                service.MockUserRepository
                .Verify(r => r.CommitChanges());
            }
Ejemplo n.º 5
0
            public void SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user = new User {
                    EmailAddress           = "*****@*****.**",
                    EmailAllowed           = true,
                    EmailConfirmationToken = null
                };
                var service = new TestableUserService();

                service.MockUserRepository
                .Setup(r => r.GetAll())
                .Returns(new[] { user }.AsQueryable());

                service.UpdateProfile(user, "*****@*****.**", true);

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.MockUserRepository
                .Verify(r => r.CommitChanges());
            }
Ejemplo n.º 6
0
            public void ThrowsArgumentExceptionForNullUser()
            {
                var service = new TestableUserService();

                ContractAssert.ThrowsArgNull(() => service.UpdateProfile(null, "*****@*****.**", emailAllowed: true), "user");
            }
Ejemplo n.º 7
0
            public void ThrowsArgumentExceptionForNullUser()
            {
                var service = new TestableUserService();

                ContractAssert.ThrowsArgNull(() => service.UpdateProfile(null, emailAllowed: true), "user");
            }
Ejemplo n.º 8
0
            public void SavesEmailAllowedSetting()
            {
                var user = new User { EmailAddress = "*****@*****.**", EmailAllowed = true };
                var service = new TestableUserService();
                service.MockUserRepository
                       .Setup(r => r.GetAll())
                       .Returns(new[] { user }.AsQueryable());

                service.UpdateProfile(user, false);

                Assert.Equal(false, user.EmailAllowed);
                service.MockUserRepository
                       .Verify(r => r.CommitChanges());
            }
Ejemplo n.º 9
0
            public void DoesNotChangeConfirmationTokenButUserHasPendingEmailChange()
            {
                var user = new User { EmailAddress = "*****@*****.**", EmailConfirmationToken = "pending-token" };
                var service = new TestableUserService();

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Equal("pending-token", user.EmailConfirmationToken);
            }
Ejemplo n.º 10
0
            public void DoesNotSetConfirmationTokenWhenEmailAddressNotChanged()
            {
                var user = new User { EmailAddress = "*****@*****.**" };
                var service = new TestableUserService();

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Null(user.EmailConfirmationToken);
            }
Ejemplo n.º 11
0
            public void SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**",
                    EmailAllowed = true,
                    EmailConfirmationToken = null
                };
                var service = new TestableUserService();
                service.MockUserRepository
                       .Setup(r => r.GetAll())
                       .Returns(new[] { user }.AsQueryable());

                service.UpdateProfile(user, "*****@*****.**", true);

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.MockUserRepository
                       .Verify(r => r.CommitChanges());
            }
Ejemplo n.º 12
0
            public void DoesNotSetConfirmationTokenWhenEmailAddressNotChanged()
            {
                var user = new User { EmailAddress = "*****@*****.**" };
                var service = new TestableUserService();
                service.MockCrypto
                       .Setup(c => c.GenerateToken())
                       .Returns("token");

                service.UpdateProfile(user, "*****@*****.**", emailAllowed: true);

                Assert.Null(user.EmailConfirmationToken);
            }