本文整理汇总了C#中ScenarioOptions类的典型用法代码示例。如果您正苦于以下问题:C# ScenarioOptions类的具体用法?C# ScenarioOptions怎么用?C# ScenarioOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScenarioOptions类属于命名空间,在下文中一共展示了ScenarioOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsInvalidWhen_MatchesUnintendedEntity
public void IsInvalidWhen_MatchesUnintendedEntity()
{
var confirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword)
{
ExpiresOnUtc = DateTime.UtcNow.AddMinutes(-1),
};
var command = new ResetPasswordCommand
{
Token = confirmation.Token,
};
var scenarioOptions = new ScenarioOptions
{
EmailConfirmation = confirmation,
Command = command,
};
var validator = CreateValidator(scenarioOptions);
var results = validator.Validate(command);
results.IsValid.ShouldBeFalse();
results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
var error = results.Errors.SingleOrDefault(e => e.PropertyName == "Token");
error.ShouldNotBeNull();
// ReSharper disable PossibleNullReferenceException
error.ErrorMessage.ShouldEqual(string.Format(
ValidateEmailConfirmation.FailedBecauseIntentWasIncorrect,
confirmation.Intent, confirmation.Token));
// ReSharper restore PossibleNullReferenceException
}
示例2: IsInvalidWhen_MatchesNoEntity
public void IsInvalidWhen_MatchesNoEntity()
{
var command = new ResetPasswordCommand
{
Token = Guid.NewGuid()
};
var scenarioOptions = new ScenarioOptions
{
Command = command,
EmailConfirmation = new EmailConfirmation(EmailConfirmationIntent.CreatePassword),
};
var validator = CreateValidator(scenarioOptions);
var results = validator.Validate(command);
results.IsValid.ShouldBeFalse();
results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
var error = results.Errors.SingleOrDefault(e => e.PropertyName == "Token");
error.ShouldNotBeNull();
// ReSharper disable PossibleNullReferenceException
error.ErrorMessage.ShouldEqual(string.Format(
ValidateEmailConfirmation.FailedBecauseTokenMatchedNoEntity,
command.Token));
// ReSharper restore PossibleNullReferenceException
}
示例3: ExecutesNoQuery_WhenEmailArgIsNull
public void ExecutesNoQuery_WhenEmailArgIsNull()
{
var scenarioOptions = new ScenarioOptions();
var controller = CreateController(scenarioOptions);
controller.ByEmail(null);
scenarioOptions.MockQueryProcessor.Verify(m => m.Execute(
It.Is(PersonQueryBasedOn(null))),
Times.Never());
}
示例4: ExecutesQuery_ToGetPersonByEmail
public void ExecutesQuery_ToGetPersonByEmail()
{
const string email = "test";
var scenarioOptions = new ScenarioOptions();
var controller = CreateController(scenarioOptions);
scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(
It.Is(PersonQueryBasedOn(email))))
.Returns(null as Person);
controller.ByEmail(email);
scenarioOptions.MockQueryProcessor.Verify(m => m.Execute(
It.Is(PersonQueryBasedOn(email))),
Times.Once());
}
示例5: GeneratesSecretCode_WithTwelveCharacters
public void GeneratesSecretCode_WithTwelveCharacters()
{
const string emailAddress = "someone";
var command = new SendConfirmEmailMessageCommand
{
EmailAddress = emailAddress,
Intent = EmailConfirmationIntent.ResetPassword,
SendFromUrl = "test",
};
var scenarioOptions = new ScenarioOptions(command);
var handler = CreateHandler(scenarioOptions);
handler.Handle(command);
scenarioOptions.OutConfirmation.SecretCode.Length.ShouldEqual(12);
}
示例6: ExecutesQuery_ForPerson
public void ExecutesQuery_ForPerson()
{
const string emailAddress = "someone";
var command = new SendConfirmEmailMessageCommand
{
EmailAddress = emailAddress,
Intent = EmailConfirmationIntent.ResetPassword,
SendFromUrl = "test",
};
var scenarioOptions = new ScenarioOptions(command);
var handler = CreateHandler(scenarioOptions);
handler.Handle(command);
scenarioOptions.Entities.Verify(m => m.Get<Person>(),
Times.Once());
}
示例7: IsInvalidWhen_IsNull
public void IsInvalidWhen_IsNull()
{
var command = new SendConfirmEmailMessageCommand();
var scenarioOptions = new ScenarioOptions();
var validator = CreateValidator(scenarioOptions);
var results = validator.Validate(command);
results.IsValid.ShouldBeFalse();
results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
var error = results.Errors.SingleOrDefault(e => e.PropertyName == PropertyName);
error.ShouldNotBeNull();
// ReSharper disable PossibleNullReferenceException
error.ErrorMessage.ShouldEqual(
ValidateEmailAddress.FailedBecauseValueWasEmpty);
// ReSharper restore PossibleNullReferenceException
}
示例8: IsInvalidWhen_IsEmpty
public void IsInvalidWhen_IsEmpty()
{
var command = new RedeemEmailConfirmationCommand { Token = Guid.Empty };
var scenarioOptions = new ScenarioOptions();
var validator = CreateValidator(scenarioOptions);
var results = validator.Validate(command);
results.IsValid.ShouldBeFalse();
results.Errors.Count.ShouldBeInRange(1, int.MaxValue);
var error = results.Errors.SingleOrDefault(e => e.PropertyName == "Token");
error.ShouldNotBeNull();
// ReSharper disable PossibleNullReferenceException
error.ErrorMessage.ShouldEqual(string.Format(
ValidateEmailConfirmation.FailedBecauseTokenWasEmpty,
Guid.Empty));
// ReSharper restore PossibleNullReferenceException
}
示例9: ThrowsNullReferenceException_WhenUserIsNull
public void ThrowsNullReferenceException_WhenUserIsNull()
{
var scenarioOptions = new ScenarioOptions();
var controller = CreateController(scenarioOptions);
scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(It.IsAny<GetMyEmailAddressByNumberQuery>()))
.Returns(null as EmailAddress);
NullReferenceException exception = null;
try
{
controller.Get();
}
catch (NullReferenceException ex)
{
exception = ex;
}
exception.ShouldNotBeNull();
}
示例10: CreatesConfrimation_With_EmailAddres_Intent_AndSecretCode
public void CreatesConfrimation_With_EmailAddres_Intent_AndSecretCode()
{
const string emailAddress = "someone";
var command = new SendConfirmEmailMessageCommand
{
EmailAddress = emailAddress,
Intent = EmailConfirmationIntent.CreatePassword,
SendFromUrl = "test",
};
var scenarioOptions = new ScenarioOptions(command);
var handler = CreateHandler(scenarioOptions);
handler.Handle(command);
scenarioOptions.Entities.Verify(m => m.
Create(It.Is(ConfirmationEntityBasedOn(scenarioOptions))),
Times.Once());
scenarioOptions.OutConfirmation.EmailAddress.ShouldEqual(scenarioOptions.Person.GetEmail(emailAddress));
scenarioOptions.OutConfirmation.Intent.ShouldEqual(command.Intent);
}
示例11: ExecutesQuery_ToGenerateDisplayName
public void ExecutesQuery_ToGenerateDisplayName()
{
var model = new GenerateDisplayNameForm
{
Salutation = "Mr",
FirstName = "Adam",
MiddleName = "B",
LastName = "West",
Suffix = "Sr.",
};
var scenarioOptions = new ScenarioOptions();
var controller = CreateController(scenarioOptions);
scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(
It.Is(GenerateDisplayNameQueryBasedOn(model))))
.Returns("derived display name");
controller.GenerateDisplayName(model);
scenarioOptions.MockQueryProcessor.Verify(m => m.Execute(
It.Is(GenerateDisplayNameQueryBasedOn(model))),
Times.Once());
}
示例12: MessageEntityBasedOn
private static Expression<Func<EmailMessage, bool>> MessageEntityBasedOn(ScenarioOptions scenarioOptions)
{
return e => e == scenarioOptions.EmailMessage;
}
示例13: NestedCommandBasedOn
private static Expression<Func<SendEmailMessageCommand, bool>> NestedCommandBasedOn(ScenarioOptions scenarioOptions)
{
return c =>
c.PersonId == scenarioOptions.EmailMessage.ToPerson.RevisionId &&
c.MessageNumber == scenarioOptions.EmailMessage.Number
;
}
示例14: CompositionQueryBasedOn
private static Expression<Func<ComposeEmailMessageQuery, bool>> CompositionQueryBasedOn(ScenarioOptions scenarioOptions)
{
return q =>
q.Template == scenarioOptions.EmailTemplate &&
q.ToEmailAddress == scenarioOptions.Person.GetEmail(scenarioOptions.Command.EmailAddress)
;
}
示例15: ConfirmationEntityBasedOn
private static Expression<Func<EmailConfirmation, bool>> ConfirmationEntityBasedOn(ScenarioOptions scenarioOptions)
{
return e =>
e.EmailAddress == scenarioOptions.Person.GetEmail(scenarioOptions.Command.EmailAddress) &&
e.Intent == scenarioOptions.Command.Intent
;
}