• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ScenarioOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ScenarioOptions的典型用法代码示例。如果您正苦于以下问题:C# ScenarioOptions类的具体用法?C# ScenarioOptions怎么用?C# ScenarioOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScenarioOptions类属于命名空间,在下文中一共展示了ScenarioOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: CreateHandler

        private static SendConfirmEmailMessageHandler CreateHandler(ScenarioOptions scenarioOptions)
        {
            var queryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict);
            scenarioOptions.QueryProcessor = queryProcessor;
            queryProcessor.Setup(m => m
                .Execute(It.Is(EmailTemplateQueryBasedOn(scenarioOptions.Command))))
                .Returns(scenarioOptions.EmailTemplate);
            queryProcessor.Setup(m => m
                .Execute(It.Is(FormattersQueryBasedOn(scenarioOptions))))
                .Returns(null as IDictionary<string, string>);
            queryProcessor.Setup(m => m
                .Execute(It.Is(CompositionQueryBasedOn(scenarioOptions))))
                .Returns(scenarioOptions.EmailMessage);

            var entities = new Mock<ICommandEntities>(MockBehavior.Strict).Initialize();
            scenarioOptions.Entities = entities;
            entities.Setup(m => m.Get<Person>()).Returns(new[] { scenarioOptions.Person }.AsQueryable);
            entities.Setup(m => m.Create(It.Is(ConfirmationEntityBasedOn(scenarioOptions))))
                .Callback((Entity entity) => scenarioOptions.OutConfirmation = (EmailConfirmation)entity);
            entities.Setup(m => m.Create(It.Is(MessageEntityBasedOn(scenarioOptions))));

            var nestedHandler = new Mock<IHandleCommands<SendEmailMessageCommand>>(MockBehavior.Strict);
            scenarioOptions.NestedHandler = nestedHandler;
            nestedHandler.Setup(m => m.Handle(It.Is(NestedCommandBasedOn(scenarioOptions))));

            return new SendConfirmEmailMessageHandler(queryProcessor.Object, entities.Object, nestedHandler.Object);
        }
开发者ID:danludwig,项目名称:UCosmic,代码行数:27,代码来源:SendConfirmEmailMessageHandlerFacts.cs


示例17: FormattersQueryBasedOn

 private static Expression<Func<GetConfirmEmailFormattersQuery, bool>> FormattersQueryBasedOn(ScenarioOptions scenarioOptions)
 {
     return e =>
         e.Confirmation.EmailAddress == scenarioOptions.Person.GetEmail(scenarioOptions.Command.EmailAddress) &&
         e.Confirmation.Intent == scenarioOptions.Command.Intent
     ;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:7,代码来源:SendConfirmEmailMessageHandlerFacts.cs


示例18: CreatesEmailMessage

            public void CreatesEmailMessage()
            {
                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(MessageEntityBasedOn(scenarioOptions))),
                    Times.Once());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:18,代码来源:SendConfirmEmailMessageHandlerFacts.cs


示例19: ExecutesCommand_WhenAction_IsValid

            public void ExecutesCommand_WhenAction_IsValid()
            {
                const string principalIdentityName = "[email protected]";
                const int establishmentId = 8;
                const string jobTitles = "job titles";
                const EmployeeOrStudentAffiliate employeeOrStudentAffiliation
                    = EmployeeOrStudentAffiliate.StudentOnly;
                const string returnUrl = "http://www.site.tld";
                var scenarioOptions = new ScenarioOptions
                {
                    PrincipalIdentityName = principalIdentityName,
                };
                var model = new UpdateAffiliationForm
                {
                    JobTitles = jobTitles,
                    EstablishmentId = establishmentId,
                    EmployeeOrStudentAffiliation = employeeOrStudentAffiliation,
                    IsClaimingInternationalOffice = true,
                    ReturnUrl = returnUrl,
                };
                var controller = CreateController(scenarioOptions);
                scenarioOptions.MockCommandHandler.Setup(m => m.Handle(
                    It.Is(CommandBasedOn(model, principalIdentityName))));

                controller.Put(model);

                scenarioOptions.MockCommandHandler.Verify(m =>
                    m.Handle(It.Is(CommandBasedOn(model, principalIdentityName))),
                        Times.Once());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:30,代码来源:UpdateAffiliationControllerFacts.cs


示例20: ExecutesQuery_ForAffiliation_ByPrincipalAndEstablishmentId

            public void ExecutesQuery_ForAffiliation_ByPrincipalAndEstablishmentId()
            {
                const int establishmentId = 2;
                const string userName = "[email protected]";
                var scenarioOptions = new ScenarioOptions
                {
                    PrincipalIdentityName = userName,
                };
                var controller = CreateController(scenarioOptions);
                scenarioOptions.MockQueryProcessor.Setup(m => m.Execute(
                    It.Is(AffiliationQueryBasedOn(userName, establishmentId))))
                        .Returns(null as Affiliation);

                controller.Get(establishmentId);

                scenarioOptions.MockQueryProcessor.Verify(m => m.Execute(
                    It.Is(AffiliationQueryBasedOn(userName, establishmentId))),
                        Times.Once());
            }
开发者ID:danludwig,项目名称:UCosmic,代码行数:19,代码来源:UpdateAffiliationControllerFacts.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Scene类代码示例发布时间:2022-05-24
下一篇:
C# Scenario类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap