コード例 #1
0
            public void WhenAdminIsOrganization_ReturnsFalse()
            {
                // Arrange
                var service      = new TestableUserService();
                var fakes        = new Fakes();
                var user         = fakes.User;
                var organization = fakes.Organization;

                var passwordConfigMock = new Mock <ILoginDiscontinuationConfiguration>();

                passwordConfigMock
                .Setup(x => x.AreOrganizationsSupportedForUser(user))
                .Returns(true);

                service.MockConfigObjectService
                .Setup(x => x.LoginDiscontinuationConfiguration)
                .Returns(passwordConfigMock.Object);

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(user, organization, out errorReason);

                // Assert
                Assert.False(result);
                Assert.Equal(errorReason, String.Format(CultureInfo.CurrentCulture,
                                                        Strings.TransformAccount_AdminAccountIsOrganization, organization.Username));
            }
コード例 #2
0
            public void WhenAccountHasMemberships_ReturnsFalse()
            {
                // Arrange
                var service = new TestableUserService();
                var fakes   = new Fakes();

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(fakes.OrganizationCollaborator, out errorReason);

                // Assert
                Assert.False(result);
                Assert.Equal(errorReason, String.Format(CultureInfo.CurrentCulture,
                                                        Strings.TransformAccount_AccountHasMemberships, fakes.OrganizationCollaborator.Username));
            }
コード例 #3
0
            public void WhenAccountIsInWhitelist_ReturnsTrue()
            {
                // Arrange
                var service = new TestableUserService();

                service.MockConfig.SetupGet(c => c.OrganizationsEnabledForDomains).Returns(new[] { "example.com" });
                var fakes = new Fakes();

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(fakes.User, out errorReason);

                // Assert
                Assert.True(result);
            }
コード例 #4
0
            public void WhenAdminIsOrganization_ReturnsFalse()
            {
                // Arrange
                var service = new TestableUserService();

                service.MockConfig.SetupGet(c => c.OrganizationsEnabledForDomains).Returns(new[] { "example.com" });
                var fakes = new Fakes();

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(fakes.User, fakes.Organization, out errorReason);

                // Assert
                Assert.False(result);
                Assert.Equal(errorReason, String.Format(CultureInfo.CurrentCulture,
                                                        Strings.TransformAccount_AdminAccountIsOrganization, fakes.Organization.Username));
            }
コード例 #5
0
            public void WhenAccountIsNotConfirmed_ReturnsFalse()
            {
                // Arrange
                var service         = new TestableUserService();
                var unconfirmedUser = new User()
                {
                    UnconfirmedEmailAddress = "*****@*****.**"
                };

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(unconfirmedUser, out errorReason);

                // Assert
                Assert.False(result);
                Assert.Equal(errorReason, String.Format(CultureInfo.CurrentCulture,
                                                        Strings.TransformAccount_AccountNotConfirmed, unconfirmedUser.Username));
            }
コード例 #6
0
            public void WhenAccountIsInWhitelist_ReturnsTrue()
            {
                // Arrange
                var service = new TestableUserService();
                var fakes   = new Fakes();
                var user    = fakes.User;

                var passwordConfigMock = new Mock <ILoginDiscontinuationConfiguration>();

                passwordConfigMock
                .Setup(x => x.AreOrganizationsSupportedForUser(user))
                .Returns(true);

                service.MockConfigObjectService
                .Setup(x => x.LoginDiscontinuationConfiguration)
                .Returns(passwordConfigMock.Object);

                // Act
                string errorReason;
                var    result = service.CanTransformUserToOrganization(user, out errorReason);

                // Assert
                Assert.True(result);
            }