本文整理汇总了C#中BrockAllen.MembershipReboot.Test.Accounts.MockUserAccountService.MockUserAccounts方法的典型用法代码示例。如果您正苦于以下问题:C# MockUserAccountService.MockUserAccounts方法的具体用法?C# MockUserAccountService.MockUserAccounts怎么用?C# MockUserAccountService.MockUserAccounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BrockAllen.MembershipReboot.Test.Accounts.MockUserAccountService
的用法示例。
在下文中一共展示了MockUserAccountService.MockUserAccounts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UsernameMustNotAlreadyExist_UsernameExistsInService_Fails
public void UsernameMustNotAlreadyExist_UsernameExistsInService_Fails()
{
var mockSvc = new MockUserAccountService();
var acct1 = new MockUserAccount(mockSvc.SecuritySettings.DefaultTenant, "u1", "p1", "[email protected]");
mockSvc.MockUserAccounts(acct1);
var acct2 = new MockUserAccount(mockSvc.SecuritySettings.DefaultTenant, "u1", "p1", "[email protected]");
var result = UserAccountValidation.UsernameMustNotAlreadyExist.Validate(mockSvc.Object, acct2.Object, acct2.Object.Username);
Assert.IsNotNull(result);
}
示例2: EmailMustNotAlreadyExist_EmailDoesNotExistsInService_Succeeds
public void EmailMustNotAlreadyExist_EmailDoesNotExistsInService_Succeeds()
{
var mockSvc = new MockUserAccountService();
var acct1 = new MockUserAccount(mockSvc.SecuritySettings.DefaultTenant, "u1", "p1", "[email protected]");
mockSvc.MockUserAccounts(acct1);
var acct2 = new MockUserAccount(mockSvc.SecuritySettings.DefaultTenant, "u1", "p1", "[email protected]");
var result = UserAccountValidation.EmailMustNotAlreadyExist.Validate(mockSvc.Object, acct2.Object, acct2.Object.Email);
Assert.IsNull(result);
}
示例3: ValidKey_MultipleMatches_Throws
public void ValidKey_MultipleMatches_Throws()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, VerificationKey = "a" },
new UserAccount { ID = b, VerificationKey = "b" },
new UserAccount { ID = c, VerificationKey = "b" });
var result = sub.Object.GetByVerificationKey("b");
}
示例4: ValidKey_ReturnsCorrectResult
public void ValidKey_ReturnsCorrectResult()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, VerificationKey = "a" },
new UserAccount { ID = b, VerificationKey = "b" },
new UserAccount { ID = c, VerificationKey = "c" });
var result = sub.Object.GetByVerificationKey("b");
Assert.AreEqual(b, result.ID);
}
示例5: PassInvalidEmail_ReturnsNull
public void PassInvalidEmail_ReturnsNull()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = sub.SecuritySettings.DefaultTenant, Email = "a" },
new UserAccount { ID = b, Tenant = sub.SecuritySettings.DefaultTenant, Email = "b" },
new UserAccount { ID = c, Tenant = sub.SecuritySettings.DefaultTenant, Email = "c" });
var result = sub.Object.GetByEmail("d");
Assert.IsNull(result);
}
示例6: PassValidEmail_MultipleMatches_Throws
public void PassValidEmail_MultipleMatches_Throws()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = sub.SecuritySettings.DefaultTenant, Email = "a" },
new UserAccount { ID = b, Tenant = sub.SecuritySettings.DefaultTenant, Email = "a" },
new UserAccount { ID = c, Tenant = sub.SecuritySettings.DefaultTenant, Email = "c" });
sub.Object.GetByEmail("a");
}
示例7: PassValidUsername_MultipleMatches_Throws
public void PassValidUsername_MultipleMatches_Throws()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "a" },
new UserAccount { ID = b, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "a" },
new UserAccount { ID = c, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "c" });
sub.Object.GetByUsername("a");
}
示例8: MultiTenantNotEnabled_ReturnsCorrectValues
public void MultiTenantNotEnabled_ReturnsCorrectValues()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = sub.SecuritySettings.DefaultTenant, Email = "a" },
new UserAccount { ID = b, Tenant = sub.SecuritySettings.DefaultTenant, Email = "b" },
new UserAccount { ID = c, Tenant = "t2", Email = "a" });
Assert.IsTrue(sub.Object.EmailExists("a"));
Assert.IsTrue(sub.Object.EmailExists("b"));
Assert.IsTrue(sub.Object.EmailExists(sub.SecuritySettings.DefaultTenant, "a"));
Assert.IsTrue(sub.Object.EmailExists("t1", "b"));
Assert.IsTrue(sub.Object.EmailExists("t2", "a"));
Assert.IsFalse(sub.Object.EmailExists("c"));
Assert.IsFalse(sub.Object.EmailExists("t2", "c"));
}
示例9: MultiTenantEnabled_NullTenant_ReturnsEmptyResults
public void MultiTenantEnabled_NullTenant_ReturnsEmptyResults()
{
var sub = new MockUserAccountService();
sub.SecuritySettings.MultiTenant = true;
sub.MockUserAccounts(
new UserAccount { Tenant = "a" },
new UserAccount { Tenant = "a" },
new UserAccount { Tenant = "b" });
var result = sub.Object.GetAll(null);
Assert.AreEqual(0, result.Count());
}
示例10: ValidAccount_CallsAccount
public void ValidAccount_CallsAccount()
{
var sub = new MockUserAccountService();
sub.SecuritySettings.DefaultTenant = "tenant";
var account = new MockUserAccount("tenant", "user", "pass", "[email protected]");
sub.MockUserAccounts(account.Object);
var result = sub.Object.IsPasswordExpired("tenant", "user");
account.Verify(x => x.GetIsPasswordExpired(It.IsAny<int>()));
}
示例11: ValidUser_RepositorySaved
public void ValidUser_RepositorySaved()
{
var sub = new MockUserAccountService();
var user = new MockUserAccount(sub.SecuritySettings.DefaultTenant, "user", "foo", "[email protected]");
sub.MockUserAccounts(user.Object);
sub.Object.SetPassword("user", "pass");
sub.UserAccountRepository.Verify(x => x.Update(user.Object));
}
示例12: ValidUser_SetPasswordCalled
public void ValidUser_SetPasswordCalled()
{
var sub = new MockUserAccountService();
var user = new MockUserAccount(sub.SecuritySettings.DefaultTenant, "user", "foo", "[email protected]");
sub.MockUserAccounts(user.Object);
sub.Object.SetPassword("user", "pass");
user.Verify(x => x.SetPassword("pass"));
}
示例13: NoUser_Throws
public void NoUser_Throws()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(new UserAccount { Tenant = "tenant", Username = "user" });
sub.Object.SetPassword("tenant", "user2", "pass");
}
示例14: UsernamesUniqueAcrossTenants_CorrectResultsReturned
public void UsernamesUniqueAcrossTenants_CorrectResultsReturned()
{
SecuritySettings.Instance.MultiTenant = true;
SecuritySettings.Instance.UsernamesUniqueAcrossTenants = true;
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = "t1", Username = "a" },
new UserAccount { ID = b, Tenant = "t1", Username = "b" },
new UserAccount { ID = c, Tenant = "t2", Username = "c" });
Assert.IsTrue(sub.Object.UsernameExists("a"));
Assert.IsTrue(sub.Object.UsernameExists("t1", "a"));
Assert.IsTrue(sub.Object.UsernameExists("t2", "a"));
Assert.IsTrue(sub.Object.UsernameExists("t3", "a"));
Assert.IsFalse(sub.Object.UsernameExists("d"));
Assert.IsFalse(sub.Object.UsernameExists("t1", "d"));
Assert.IsFalse(sub.Object.UsernameExists("t2", "d"));
Assert.IsFalse(sub.Object.UsernameExists("t3", "d"));
}
示例15: PassInvalidUsername_ReturnsNull
public void PassInvalidUsername_ReturnsNull()
{
var sub = new MockUserAccountService();
sub.MockUserAccounts(
new UserAccount { ID = a, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "a" },
new UserAccount { ID = b, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "b" },
new UserAccount { ID = c, Tenant = SecuritySettings.Instance.DefaultTenant, Username = "c" });
var result = sub.Object.GetByUsername("d");
Assert.IsNull(result);
}