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)); }
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)); }
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); }
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)); }
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)); }
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); }