当前位置: 首页>>代码示例>>C#>>正文


C# ScenarioOptions类代码示例

本文整理汇总了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
            }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:29,代码来源:ResetPasswordValidatorFacts.cs

示例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
            }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:25,代码来源:ResetPasswordValidatorFacts.cs

示例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());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:11,代码来源:PersonInfoControllerFacts.cs

示例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());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:15,代码来源:PersonInfoControllerFacts.cs

示例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);
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:16,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例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());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:17,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例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
            }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:17,代码来源:SendConfirmEmailMessageValidatorFacts.cs

示例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
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:18,代码来源:RedeemEmailConfirmationValidatorFacts.cs

示例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();
            }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:19,代码来源:UpdateNameControllerFacts.cs

示例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);
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:20,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例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());
            }
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:22,代码来源:PersonNameControllerFacts.cs

示例12: MessageEntityBasedOn

 private static Expression<Func<EmailMessage, bool>> MessageEntityBasedOn(ScenarioOptions scenarioOptions)
 {
     return e => e == scenarioOptions.EmailMessage;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:4,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例13: NestedCommandBasedOn

 private static Expression<Func<SendEmailMessageCommand, bool>> NestedCommandBasedOn(ScenarioOptions scenarioOptions)
 {
     return c =>
         c.PersonId == scenarioOptions.EmailMessage.ToPerson.RevisionId &&
         c.MessageNumber == scenarioOptions.EmailMessage.Number
     ;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:7,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例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)
     ;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:7,代码来源:SendConfirmEmailMessageHandlerFacts.cs

示例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
     ;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:7,代码来源:SendConfirmEmailMessageHandlerFacts.cs


注:本文中的ScenarioOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。