本文整理汇总了C#中MockUserAccount类的典型用法代码示例。如果您正苦于以下问题:C# MockUserAccount类的具体用法?C# MockUserAccount怎么用?C# MockUserAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockUserAccount类属于命名空间,在下文中一共展示了MockUserAccount类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EmailIsValidFormat_ValidEmail_Succeeds
public void EmailIsValidFormat_ValidEmail_Succeeds()
{
var mockSvc = new MockUserAccountService();
var acct = new MockUserAccount();
var result = UserAccountValidation.EmailIsValidFormat.Validate(mockSvc.Object, acct.Object, "[email protected]");
Assert.IsNull(result);
}
开发者ID:KamoHaladus,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:UserAccountValidationTests.cs
示例2: EmailIsValidFormat_InValidEmail_Fails
public void EmailIsValidFormat_InValidEmail_Fails()
{
var mockSvc = new MockUserAccountService();
var acct = new MockUserAccount();
var result = UserAccountValidation.EmailIsValidFormat.Validate(mockSvc.Object, acct.Object, "test");
Assert.IsNotNull(result);
}
开发者ID:KamoHaladus,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:UserAccountValidationTests.cs
示例3: 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);
}
开发者ID:KamoHaladus,项目名称:BrockAllen.MembershipReboot,代码行数:10,代码来源:UserAccountValidationTests.cs
示例4: 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);
}
开发者ID:KamoHaladus,项目名称:BrockAllen.MembershipReboot,代码行数:10,代码来源:UserAccountValidationTests.cs
示例5: BasicProperties_Assigned
public void BasicProperties_Assigned()
{
var sub = new MockUserAccount("ten", "user", "pass", "email");
var now = new DateTime(2000, 2, 3, 8, 30, 0);
sub.Setup(x => x.UtcNow).Returns(now);
Assert.AreEqual("ten", sub.Object.Tenant);
Assert.AreEqual("user", sub.Object.Username);
Assert.AreEqual("email", sub.Object.Email);
Assert.AreEqual(now, sub.Object.Created);
sub.Verify(x => x.SetPassword("pass"));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:11,代码来源:UserAccountTests.cs
示例6: Process_FormatReturnsNoMessage_DoesNotSendMessage
public void Process_FormatReturnsNoMessage_DoesNotSendMessage()
{
var mockMF = new Mock<IMessageFormatter>();
var mockMD = new Mock<IMessageDelivery>();
var sub = new EmailEventHandler(mockMF.Object, mockMD.Object);
var mockAcct = new MockUserAccount();
var mockEvt = new Mock<UserAccountEvent>();
mockEvt.Object.Account = mockAcct.Object;
sub.Process(mockEvt.Object);
mockMD.Verify(x => x.Send(It.IsAny<Message>()), Times.Never());
}
开发者ID:KeithBarrows,项目名称:BrockAllen.MembershipReboot,代码行数:14,代码来源:EmailEventHandlerTests.cs
示例7: Process_FormatReturnsMessage_SendsMessage
public void Process_FormatReturnsMessage_SendsMessage()
{
var msg = new Message();
var mockMF = new Mock<IMessageFormatter>();
var mockMD = new Mock<IMessageDelivery>();
mockMF.Setup(x => x.Format(It.IsAny<UserAccountEvent>())).Returns(msg);
var sub = new EmailEventHandler(mockMF.Object, mockMD.Object);
var mockAcct = new MockUserAccount();
var mockEvt = new Mock<UserAccountEvent>();
mockEvt.Object.Account = mockAcct.Object;
sub.Process(mockEvt.Object);
mockMD.Verify(x => x.Send(msg));
}
开发者ID:KeithBarrows,项目名称:BrockAllen.MembershipReboot,代码行数:16,代码来源:EmailEventHandlerTests.cs
示例8: Process_ExplicitEmailParam_UsesExplicitEmail
public void Process_ExplicitEmailParam_UsesExplicitEmail()
{
var msg = new Message();
var mockMF = new Mock<IMessageFormatter>();
var mockMD = new Mock<IMessageDelivery>();
mockMF.Setup(x => x.Format(It.IsAny<UserAccountEvent>())).Returns(msg);
var sub = new EmailEventHandler(mockMF.Object, mockMD.Object);
var mockAcct = new MockUserAccount();
mockAcct.Object.Email = "foo";
var mockEvt = new Mock<UserAccountEvent>();
mockEvt.Object.Account = mockAcct.Object;
sub.Process(mockEvt.Object, "bar");
Assert.AreEqual("bar", msg.To);
}
开发者ID:KeithBarrows,项目名称:BrockAllen.MembershipReboot,代码行数:17,代码来源:EmailEventHandlerTests.cs
示例9: Validate_AllCallsSucceed_CallsAllValidators
public void Validate_AllCallsSucceed_CallsAllValidators()
{
var mockVal1 = new Mock<IValidator>();
var mockVal2 = new Mock<IValidator>();
var sub = new AggregateValidator();
sub.Add(mockVal1.Object);
sub.Add(mockVal2.Object);
var svc = new MockUserAccountService();
var ua = new MockUserAccount();
var val = "test";
var result = sub.Validate(svc.Object, ua.Object, val);
mockVal1.Verify(x=>x.Validate(svc.Object, ua.Object, val));
mockVal2.Verify(x=>x.Validate(svc.Object, ua.Object, val));
}
开发者ID:KeithBarrows,项目名称:BrockAllen.MembershipReboot,代码行数:17,代码来源:AggregateValidatorTests.cs
示例10: CallsAuthenticateOnUserAccount
public void CallsAuthenticateOnUserAccount()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Object.Authenticate(account.Object, "pass", 10, TimeSpan.FromDays(1));
account.Verify(x => x.Authenticate("pass", 10, TimeSpan.FromDays(1)));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:UserAccountServiceTests.cs
示例11: AllowAccountDeletionDisabled_AccountIsNotVerified_CallsRemoveOnRepo
public void AllowAccountDeletionDisabled_AccountIsNotVerified_CallsRemoveOnRepo()
{
SecuritySettings.Instance.AllowAccountDeletion = false;
var sub = new MockUserAccountService();
var account = new MockUserAccount();
account.Object.IsAccountVerified = false;
sub.Object.DeleteAccount(account.Object);
sub.UserAccountRepository.Verify(x => x.Remove(account.Object));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:11,代码来源:UserAccountServiceTests.cs
示例12: AccountFound_DeleteAccountCalled
public void AccountFound_DeleteAccountCalled()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByUsername(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
var result = sub.Object.DeleteAccount("user");
sub.Mock.Verify(x => x.DeleteAccount(account.Object));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:8,代码来源:UserAccountServiceTests.cs
示例13: KeysMatch_DeleteAccountCalled
public void KeysMatch_DeleteAccountCalled()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
account.Object.VerificationKey = "key";
sub.Object.CancelNewAccount("key");
sub.Mock.Verify(x => x.DeleteAccount(account.Object));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:11,代码来源:UserAccountServiceTests.cs
示例14: AccountVerified_ReturnsFalse
public void AccountVerified_ReturnsFalse()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
account.Object.IsAccountVerified = true;
Assert.IsFalse(sub.Object.CancelNewAccount("key"));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:9,代码来源:UserAccountServiceTests.cs
示例15: VerifyFails_DoesNotCallNotificationService
public void VerifyFails_DoesNotCallNotificationService()
{
var sub = new MockUserAccountService();
sub.NotificationService = new Mock<INotificationService>();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
account.Setup(x => x.VerifyAccount(It.IsAny<string>())).Returns(false);
sub.Object.VerifyAccount("key");
sub.NotificationService.Verify(x => x.SendAccountVerified(It.IsAny<UserAccount>()), Times.Never());
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:12,代码来源:UserAccountServiceTests.cs
示例16: Success_CallsVerifyAccountOnUserAccountAndSaveOnRepository
public void Success_CallsVerifyAccountOnUserAccountAndSaveOnRepository()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
sub.Object.VerifyAccount("key");
account.Verify(x => x.VerifyAccount("key"));
sub.UserAccountRepository.Verify(x => x.SaveChanges());
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:11,代码来源:UserAccountServiceTests.cs
示例17: VerifyAccountReturnsFalse_ReturnsFalse
public void VerifyAccountReturnsFalse_ReturnsFalse()
{
var sub = new MockUserAccountService();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
account.Setup(x => x.VerifyAccount(It.IsAny<string>())).Returns(false);
Assert.IsFalse(sub.Object.VerifyAccount("key"));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:8,代码来源:UserAccountServiceTests.cs
示例18: UserAccountChangeEmailRequestSuccess_CallsSendChangeEmailRequestNotice
public void UserAccountChangeEmailRequestSuccess_CallsSendChangeEmailRequestNotice()
{
var sub = new MockUserAccountService();
sub.NotificationService = new Mock<INotificationService>();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByUsername(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
account.Setup(x => x.ChangeEmailRequest(It.IsAny<string>())).Returns(true);
sub.Object.ChangeEmailRequest("user", "[email protected]");
sub.NotificationService.Verify(x => x.SendChangeEmailRequestNotice(account.Object, "[email protected]"));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:10,代码来源:UserAccountServiceTests.cs
示例19: VerifySucceeds_CallsNotificationService
public void VerifySucceeds_CallsNotificationService()
{
var sub = new MockUserAccountService();
sub.NotificationService = new Mock<INotificationService>();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
account.Setup(x => x.VerifyAccount(It.IsAny<string>())).Returns(true);
sub.Object.VerifyAccount("key");
sub.NotificationService.Verify(x => x.SendAccountVerified(account.Object));
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:12,代码来源:UserAccountServiceTests.cs
示例20: UserAccountChangeEmailRequestFails_DoesNotCallSendChangeEmailRequestNotice
public void UserAccountChangeEmailRequestFails_DoesNotCallSendChangeEmailRequestNotice()
{
var sub = new MockUserAccountService();
sub.NotificationService = new Mock<INotificationService>();
var account = new MockUserAccount();
sub.Mock.Setup(x => x.GetByUsername(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
account.Setup(x => x.ChangeEmailRequest(It.IsAny<string>())).Returns(false);
sub.Object.ChangeEmailRequest("user", "[email protected]");
sub.NotificationService.Verify(x => x.SendChangeEmailRequestNotice(It.IsAny<UserAccount>(), It.IsAny<string>()), Times.Never());
}
开发者ID:rodmjay,项目名称:BrockAllen.MembershipReboot,代码行数:10,代码来源:UserAccountServiceTests.cs
注:本文中的MockUserAccount类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论