コード例 #1
0
        static SumOpTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SumOp>
            {
                Name             = "constructor should throw ArgumentException when parameter 'statements' contains a null element scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SumOp>();

                    var result = new SumOp(new[] { referenceObject.Statements.First() });

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "contains less than 2 elements", },
            });
        }
コード例 #2
0
        static CouldNotGetOrUseDeliveryChannelConfigsEventTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CouldNotGetOrUseDeliveryChannelConfigsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'getAudienceResult' GetOutcome() is not any of GetAudienceOutcome.[GotAudienceWithNoFailuresReported|GotAudienceWithReportedFailuresIgnored]",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <CouldNotGetOrUseDeliveryChannelConfigsEvent>();

                    var result = new CouldNotGetOrUseDeliveryChannelConfigsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        A.Dummy <GetAudienceResult>().Whose(_ => (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithNoFailuresReported) && (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored)),
                        referenceObject.GetDeliveryChannelConfigsResult);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "getAudienceOutcome" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CouldNotGetOrUseDeliveryChannelConfigsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'getDeliveryChannelConfigsResult' GetOutcome() is not any of GetDeliveryChannelConfigsOutcome.[CouldNotGetDeliveryChannelConfigsAndNoFailuresReported|CouldNotGetDeliveryChannelConfigsWithSomeFailuresReported|DespiteGettingDeliveryChannelConfigsFailuresPreventUsingThem]",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <CouldNotGetOrUseDeliveryChannelConfigsEvent>();

                    var result = new CouldNotGetOrUseDeliveryChannelConfigsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        referenceObject.GetAudienceResult,
                        A.Dummy <GetDeliveryChannelConfigsResult>().Whose(_ => !new[] { GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsAndNoFailuresReported, GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsWithSomeFailuresReported, GetDeliveryChannelConfigsOutcome.DespiteGettingDeliveryChannelConfigsFailuresPreventUsingThem }.Contains(_.GetOutcome())));

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "getDeliveryChannelConfigsOutcome" },
            });
        }
        static ModelPrivateSetMultilevelGrandchild1ATest()
        {
            StringRepresentationTestScenarios.RemoveAllScenarios();

            StringRepresentationTestScenarios.AddScenario(StringRepresentationTestScenario <ModelPrivateSetMultilevelGrandchild1A> .ForceGeneratedTestsToPassAndWriteMyOwnScenario);

            ConstructorArgumentValidationTestScenarios.AddScenario(
                ConstructorArgumentValidationTestScenario <ModelPrivateSetMultilevelGrandchild1A> .ConstructorCannotThrowScenario);

            ComparableTestScenarios.AddScenario(new ComparableTestScenario <ModelPrivateSetMultilevelGrandchild1A>
            {
                Name            = "Scenario 1",
                ReferenceObject = new ModelPrivateSetMultilevelGrandchild1A(1, 2, 3),
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1A(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild1A(3, 2, 1),
                    new ModelPrivateSetMultilevelGrandchild1A(0, 6, 0),
                },
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1A(1, 2, 2),
                    new ModelPrivateSetMultilevelGrandchild1A(6, -2, -1),
                    new ModelPrivateSetMultilevelGrandchild1A(0, 5, 0),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1A(2, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild1A(3, 3, 1),
                    new ModelPrivateSetMultilevelGrandchild1A(0, 7, 0),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[]
                {
                    1,
                    "dummy-string",
                    new ModelPrivateSetMultilevelGrandchild1B(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild2A(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild2B(1, 2, 3),
                },
            });
        }
コード例 #4
0
        static DeliveryChannelConfigTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <DeliveryChannelConfig>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'action' is DeliveryChannelAction.Unknown",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <DeliveryChannelConfig>();

                    var result = new DeliveryChannelConfig(
                        referenceObject.Channel,
                        DeliveryChannelAction.Unknown);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "action", "Unknown" },
            });
        }
コード例 #5
0
        static ColumnDefinitionTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ColumnDefinition>
            {
                Name             = "constructor should throw ArgumentException when parameter 'name' is not alphanumeric nor _",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ColumnDefinition>();

                    var result = new ColumnDefinition(
                        referenceObject.Name + "^",
                        referenceObject.SqlDataType);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "name", "alphanumeric" },
            });
        }
コード例 #6
0
        static BytesPayloadLinkedResourceTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <BytesPayloadLinkedResource>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'resourceKind' is BytesPayloadLinkedResourceKind.Unknown",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <BytesPayloadLinkedResource>();

                    var result = new BytesPayloadLinkedResource(
                        referenceObject.Bytes,
                        BytesPayloadLinkedResourceKind.Unknown);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "resourceKind", "Unknown", },
            });
        }
コード例 #7
0
        static RelativeCutoffTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <RelativeCutoff>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'startOrEnd' is neither ReportingPeriodComponent.Start nor ReportingPeriodComponent.End",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <RelativeCutoff>();

                    var result = new RelativeCutoff(
                        referenceObject.Duration,
                        A.Dummy <ReportingPeriodComponent>().ThatIsNotIn(new[] { ReportingPeriodComponent.Start, ReportingPeriodComponent.End }));

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "startOrEnd is neither ReportingPeriodComponent.Start nor ReportingPeriodComponent.End", },
            });
        }
        static IdentifiedSerializerRepresentationTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <IdentifiedSerializerRepresentation>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'serializationFormat' is SerializationFormat.Invalid scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <IdentifiedSerializerRepresentation>();

                    var result = new IdentifiedSerializerRepresentation(
                        referenceObject.Id,
                        referenceObject.SerializerRepresentation,
                        SerializationFormat.Invalid);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "serializationFormat", "Invalid" },
            });
        }
コード例 #9
0
        static ChannelOperationOutcomeInfoTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ChannelOperationOutcomeInfo>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'outcome' is ChannelOperationOutcome.Unknown",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ChannelOperationOutcomeInfo>();

                    var result = new ChannelOperationOutcomeInfo(
                        referenceObject.ChannelOperationTrackingCodeId,
                        referenceObject.EventType,
                        ChannelOperationOutcome.Unknown);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "Unknown", },
            });
        }
        static CouldNotGetOrUseAudienceEventTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <CouldNotGetOrUseAudienceEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'getAudienceResult' GetOutcome() is not any of GetAudienceOutcome.[CouldNotGetAudienceAndNoFailuresReported|CouldNotGetAudienceWithSomeFailuresReported|DespiteGettingAudienceFailuresPreventUsingIt]",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <CouldNotGetOrUseAudienceEvent>();

                    var result = new CouldNotGetOrUseAudienceEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        A.Dummy <GetAudienceResult>().Whose(_ => !new[] { GetAudienceOutcome.CouldNotGetAudienceAndNoFailuresReported, GetAudienceOutcome.CouldNotGetAudienceWithSomeFailuresReported, GetAudienceOutcome.DespiteGettingAudienceFailuresPreventUsingIt }.Contains(_.GetOutcome())));

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "getAudienceOutcome" },
            });
        }
コード例 #11
0
        static ChannelOperationMonitoringInfoTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ChannelOperationMonitoringInfo>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'succeededEventType' is equal to parameter 'failedEventType'",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ChannelOperationMonitoringInfo>();

                    var result = new ChannelOperationMonitoringInfo(
                        referenceObject.ChannelOperationTrackingCodeId,
                        referenceObject.SucceededEventType,
                        referenceObject.SucceededEventType);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "failedEventType", },
            });
        }
コード例 #12
0
        static SentOnSomePreparedChannelsEventTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SentOnSomePreparedChannelsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'attemptToSendNotificationResult' GetOutcome() is not AttemptToSendNotificationOutcome.SentOnSomePreparedChannels",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SentOnSomePreparedChannelsEvent>();

                    var result = new SentOnSomePreparedChannelsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        A.Dummy <AttemptToSendNotificationResult>().ThatIs(_ => _.GetOutcome() != AttemptToSendNotificationOutcome.SentOnSomePreparedChannels));

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "attemptToSendNotificationOutcome", "SentOnSomePreparedChannels" },
            });
        }
コード例 #13
0
        static UpdateStreamStoredProceduresOpTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <UpdateStreamStoredProceduresOp>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'maxConcurrentHandlingCount' is 0 scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <UpdateStreamStoredProceduresOp>();

                    var result = new UpdateStreamStoredProceduresOp(
                        referenceObject.RecordTagAssociationManagementStrategy,
                        0);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "maxConcurrentHandlingCount" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <UpdateStreamStoredProceduresOp>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'maxConcurrentHandlingCount' is negative scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <UpdateStreamStoredProceduresOp>();

                    var result = new UpdateStreamStoredProceduresOp(
                        referenceObject.RecordTagAssociationManagementStrategy,
                        A.Dummy <NegativeInteger>());

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "maxConcurrentHandlingCount" },
            });
        }
コード例 #14
0
        static ScriptedObjectTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ScriptedObject>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'databaseObjectType' is ScriptableObjectType.Invalid scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ScriptedObject>();

                    var result = new ScriptedObject(
                        referenceObject.Name,
                        ScriptableObjectType.Invalid,
                        referenceObject.DropScript,
                        referenceObject.CreateScript);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "scriptableObjectType", "Invalid" },
            });
        }
コード例 #15
0
        static ModelPrivateSetMultilevelGrandchild1BTest()
        {
            ConstructorArgumentValidationTestScenarios.AddScenario(
                ConstructorArgumentValidationTestScenario <ModelPrivateSetMultilevelGrandchild1B> .ConstructorCannotThrowScenario);

            ComparableTestScenarios.AddScenario(new ComparableTestScenario <ModelPrivateSetMultilevelGrandchild1B>
            {
                Name            = "Scenario 1",
                ReferenceObject = new ModelPrivateSetMultilevelGrandchild1B(1, 2, 3),
                ObjectsThatAreEqualToButNotTheSameAsReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1B(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild1B(3, 2, 1),
                    new ModelPrivateSetMultilevelGrandchild1B(0, 6, 0),
                },
                ObjectsThatAreLessThanReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1B(1, 2, 2),
                    new ModelPrivateSetMultilevelGrandchild1B(6, -2, -1),
                    new ModelPrivateSetMultilevelGrandchild1B(0, 5, 0),
                },
                ObjectsThatAreGreaterThanReferenceObject = new[]
                {
                    new ModelPrivateSetMultilevelGrandchild1B(2, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild1B(3, 3, 1),
                    new ModelPrivateSetMultilevelGrandchild1B(0, 7, 0),
                },
                ObjectsThatAreNotOfTheSameTypeAsReferenceObject = new object[]
                {
                    1,
                    "dummy-string",
                    new ModelPrivateSetMultilevelGrandchild1A(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild2A(1, 2, 3),
                    new ModelPrivateSetMultilevelGrandchild2B(1, 2, 3),
                },
            });
        }
コード例 #16
0
        static NotificationTrackingCodeTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(ConstructorArgumentValidationTestScenario <NotificationTrackingCode> .ConstructorCannotThrowScenario);

            StringRepresentationTestScenarios
            .AddScenario(() =>
                         new StringRepresentationTestScenario <NotificationTrackingCode>
            {
                Name = "ToString() gets friendly string representation",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                {
                    var systemUnderTest = A.Dummy <NotificationTrackingCode>();

                    var result = new SystemUnderTestExpectedStringRepresentation <NotificationTrackingCode>
                    {
                        SystemUnderTest = systemUnderTest,
                        ExpectedStringRepresentation = Invariant($"{systemUnderTest.Id}"),
                    };

                    return(result);
                },
            });
        }
コード例 #17
0
 static GetTagsFromObjectOpTObjectTest()
 {
     ConstructorArgumentValidationTestScenarios.RemoveAllScenarios();
     ConstructorArgumentValidationTestScenarios.AddScenario(
         ConstructorArgumentValidationTestScenario <GetTagsFromObjectOp <Version> > .ConstructorCannotThrowScenario);
 }
        static ProcessSendNotificationSagaOpTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ProcessSendNotificationSagaOp>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsMonitoringInfoMap' has a value that is empty",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ProcessSendNotificationSagaOp>();

                    var channelToOperationsMonitoringInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyList <ChannelOperationMonitoringInfo> >
                    {
                        {
                            new SlackDeliveryChannel(),
                            new ChannelOperationMonitoringInfo[0]
                        },
                    };

                    var result = new ProcessSendNotificationSagaOp(
                        referenceObject.NotificationTrackingCodeId,
                        channelToOperationsMonitoringInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "perChannelOperationsMonitoringInfo", "empty enumerable" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ProcessSendNotificationSagaOp>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsMonitoringInfoMap' has a value that contains a null element",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ProcessSendNotificationSagaOp>();

                    var channelToOperationsMonitoringInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyList <ChannelOperationMonitoringInfo> >
                    {
                        {
                            new SlackDeliveryChannel(),
                            new[] { A.Dummy <ChannelOperationMonitoringInfo>(), null }
                        },
                    };

                    var result = new ProcessSendNotificationSagaOp(
                        referenceObject.NotificationTrackingCodeId,
                        channelToOperationsMonitoringInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "perChannelOperationsMonitoringInfo", "null element" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <ProcessSendNotificationSagaOp>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsMonitoringInfoMap' has a value that contains two or more elements with the same tracking code",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <ProcessSendNotificationSagaOp>();

                    var channelMonitoringInfo = A.Dummy <ChannelOperationMonitoringInfo>();

                    var channelMonitoringInfo2 = A.Dummy <ChannelOperationMonitoringInfo>().DeepCloneWithChannelOperationTrackingCodeId(channelMonitoringInfo.ChannelOperationTrackingCodeId);

                    var channelToOperationsMonitoringInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyList <ChannelOperationMonitoringInfo> >
                    {
                        {
                            new SlackDeliveryChannel(),
                            new[]
                            {
                                channelMonitoringInfo,
                                A.Dummy <ChannelOperationMonitoringInfo>(),
                                channelMonitoringInfo2,
                            }
                        },
                    };

                    var result = new ProcessSendNotificationSagaOp(
                        referenceObject.NotificationTrackingCodeId,
                        channelToOperationsMonitoringInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "channelOperationTrackingCodeIds", "two or more elements that are equal" },
            });
        }
コード例 #19
0
 static GetResourceLocatorByIdOpTIdTest()
 {
     ConstructorArgumentValidationTestScenarios.RemoveAllScenarios();
     ConstructorArgumentValidationTestScenarios.AddScenario(
         ConstructorArgumentValidationTestScenario <GetResourceLocatorByIdOp <Version> > .ConstructorCannotThrowScenario);
 }
コード例 #20
0
        static ContactTest()
        {
            ConstructorArgumentValidationTestScenarios.RemoveAllScenarios();
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'email' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        null,
                        referenceObject.Vid,
                        referenceObject.Properties);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "email" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentException when parameter 'email' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.Vid,
                        referenceObject.Properties);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "email", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentException when parameter 'vid' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        referenceObject.Email,
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.Properties);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "vid", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'properties' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        referenceObject.Email,
                        referenceObject.Vid,
                        null);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "properties" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentException when parameter 'properties' is an empty dictionary scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        referenceObject.Email,
                        referenceObject.Vid,
                        new Dictionary <string, string>());

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "properties", "is an empty dictionary" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentException when parameter 'properties' does not have first name key",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        referenceObject.Email,
                        referenceObject.Vid,
                        new Dictionary <string, string>
                    {
                        { Contact.LastNamePropertyKey, A.Dummy <string>() },
                    });

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "Must have a firstName property.  Provided value is false." },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <Contact>
            {
                Name             = "constructor should throw ArgumentException when parameter 'properties' does not have last name key",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <Contact>();

                    var result = new Contact(
                        referenceObject.Email,
                        referenceObject.Vid,
                        new Dictionary <string, string>
                    {
                        { Contact.FirstNamePropertyKey, A.Dummy <string>() },
                    });

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "Must have a lastName property.  Provided value is false." },
            });
        }
コード例 #21
0
        static SqlServerStreamConfigTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SqlServerStreamConfig>
            {
                Name             = "constructor should throw ArgumentOutRangeException when parameter 'defaultConnectionTimeout' is negative",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SqlServerStreamConfig>();

                    var result = new SqlServerStreamConfig(
                        referenceObject.Name,
                        referenceObject.AccessKinds,
                        referenceObject.DefaultConnectionTimeout.Negate(),
                        referenceObject.DefaultCommandTimeout,
                        referenceObject.DefaultSerializerRepresentation,
                        referenceObject.DefaultSerializationFormat,
                        referenceObject.AllLocators);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "defaultConnectionTimeout.TotalMilliseconds" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SqlServerStreamConfig>
            {
                Name             = "constructor should throw ArgumentOutRangeException when parameter 'defaultConnectionTimeout' is negative",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SqlServerStreamConfig>();

                    var result = new SqlServerStreamConfig(
                        referenceObject.Name,
                        referenceObject.AccessKinds,
                        referenceObject.DefaultConnectionTimeout,
                        referenceObject.DefaultCommandTimeout.Negate(),
                        referenceObject.DefaultSerializerRepresentation,
                        referenceObject.DefaultSerializationFormat,
                        referenceObject.AllLocators);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "defaultCommandTimeout.TotalMilliseconds", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SqlServerStreamConfig>
            {
                Name             = "constructor should throw ArgumentOutRangeException when parameter 'defaultSerializationFormat' is SerializationFormat.Invalid",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SqlServerStreamConfig>();

                    var result = new SqlServerStreamConfig(
                        referenceObject.Name,
                        referenceObject.AccessKinds,
                        referenceObject.DefaultConnectionTimeout,
                        referenceObject.DefaultCommandTimeout,
                        referenceObject.DefaultSerializerRepresentation,
                        SerializationFormat.Invalid,
                        referenceObject.AllLocators);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "defaultSerializationFormat", "Invalid", },
            });
        }
 static ModelAllPrivateSetNullableChild1Test()
 {
     ConstructorArgumentValidationTestScenarios.AddScenario(ConstructorArgumentValidationTestScenario <ModelAllPrivateSetNullableChild1> .ConstructorCannotThrowScenario);
 }
コード例 #23
0
 static CacheStatusResultTest()
 {
     ConstructorArgumentValidationTestScenarios.RemoveAllScenarios();
     ConstructorArgumentValidationTestScenarios.AddScenario(
         ConstructorArgumentValidationTestScenario <CacheStatusResult> .ConstructorCannotThrowScenario);
 }
コード例 #24
0
        static SmtpServerConnectionDefinitionTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SmtpServerConnectionDefinition>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'port' is = 0",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SmtpServerConnectionDefinition>();

                    var result = new SmtpServerConnectionDefinition(
                        referenceObject.Host,
                        0,
                        referenceObject.SecureConnectionMethod,
                        referenceObject.Username,
                        referenceObject.ClearTextPassword);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "port", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SmtpServerConnectionDefinition>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'port' is < 0",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SmtpServerConnectionDefinition>();

                    var result = new SmtpServerConnectionDefinition(
                        referenceObject.Host,
                        A.Dummy <NegativeInteger>(),
                        referenceObject.SecureConnectionMethod,
                        referenceObject.Username,
                        referenceObject.ClearTextPassword);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "port", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <SmtpServerConnectionDefinition>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'port' is > 65535",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <SmtpServerConnectionDefinition>();

                    var result = new SmtpServerConnectionDefinition(
                        referenceObject.Host,
                        65536,
                        referenceObject.SecureConnectionMethod,
                        referenceObject.Username,
                        referenceObject.ClearTextPassword);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "port", },
            });
        }
コード例 #25
0
        static TableDescriptionTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(
                () =>
                new ConstructorArgumentValidationTestScenario <TableDescription>
            {
                Name             = "constructor should throw ArgumentException when parameter 'databaseName' is 'invalid' scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TableDescription>();

                    var result = new TableDescription(
                        "not-valid",
                        referenceObject.TableSchema,
                        referenceObject.TableName,
                        referenceObject.Columns);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[]
                {
                    "databaseName",
                    "alphanumeric",
                },
            })
            .AddScenario(
                () =>
                new ConstructorArgumentValidationTestScenario <TableDescription>
            {
                Name             = "constructor should throw ArgumentException when parameter 'tableSchema' is 'invalid' scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TableDescription>();

                    var result = new TableDescription(
                        referenceObject.DatabaseName,
                        "not-valid",
                        referenceObject.TableName,
                        referenceObject.Columns);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[]
                {
                    "tableSchema",
                    "alphanumeric",
                },
            })
            .AddScenario(
                () =>
                new ConstructorArgumentValidationTestScenario <TableDescription>
            {
                Name             = "constructor should throw ArgumentException when parameter 'tableName' is 'invalid' scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TableDescription>();

                    var result = new TableDescription(
                        referenceObject.DatabaseName,
                        referenceObject.TableSchema,
                        "not-valid",
                        referenceObject.Columns);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[]
                {
                    "tableName",
                    "alphanumeric",
                },
            });
        }
コード例 #26
0
        static AttemptToSendNotificationResultTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <AttemptToSendNotificationResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsOutcomeInfoMap' contains a value that is empty",
                ConstructionFunc = () =>
                {
                    var channelToOperationsOutcomeInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyCollection <ChannelOperationOutcomeInfo> >
                    {
                        { new SlackDeliveryChannel(), new ChannelOperationOutcomeInfo[0] },
                    };

                    var result = new AttemptToSendNotificationResult(
                        channelToOperationsOutcomeInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "perChannelOperationsOutcomeInfo", "empty enumerable", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <AttemptToSendNotificationResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsOutcomeInfoMap' contains a value that contains a null value",
                ConstructionFunc = () =>
                {
                    var channelToOperationsOutcomeInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyCollection <ChannelOperationOutcomeInfo> >
                    {
                        { new SlackDeliveryChannel(), new ChannelOperationOutcomeInfo[] { A.Dummy <ChannelOperationOutcomeInfo>(), null } },
                    };

                    var result = new AttemptToSendNotificationResult(
                        channelToOperationsOutcomeInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "perChannelOperationsOutcomeInfo", "null element", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <AttemptToSendNotificationResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'channelToOperationsOutcomeInfoMap' contains a value having duplicate tracking code ids",
                ConstructionFunc = () =>
                {
                    var channelOperationOutcomeInfo = A.Dummy <ChannelOperationOutcomeInfo>();

                    var channelOperationOutcomeInfo2 = A.Dummy <ChannelOperationOutcomeInfo>().DeepCloneWithChannelOperationTrackingCodeId(channelOperationOutcomeInfo.ChannelOperationTrackingCodeId);

                    var channelToOperationsOutcomeInfoMap =
                        new Dictionary <IDeliveryChannel, IReadOnlyCollection <ChannelOperationOutcomeInfo> >
                    {
                        {
                            new SlackDeliveryChannel(),
                            new[]
                            {
                                channelOperationOutcomeInfo,
                                channelOperationOutcomeInfo2,
                            }
                        },
                    };

                    var result = new AttemptToSendNotificationResult(
                        channelToOperationsOutcomeInfoMap);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "perChannelOperationTrackingCodeIds", "two or more elements that are equal", },
            });
        }
        static PreparedToSendOnSomeChannelsEventTest()
        {
            ConstructorArgumentValidationTestScenarios
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <PreparedToSendOnSomeChannelsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'getAudienceResult' GetOutcome() is not any of GetAudienceOutcome.[GotAudienceWithNoFailuresReported|GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored]",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <PreparedToSendOnSomeChannelsEvent>();

                    var result = new PreparedToSendOnSomeChannelsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        A.Dummy <GetAudienceResult>().Whose(_ => (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithNoFailuresReported) && (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored)),
                        referenceObject.GetDeliveryChannelConfigsResult,
                        referenceObject.PrepareToSendNotificationResult);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "getAudienceOutcome", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <PreparedToSendOnSomeChannelsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'getDeliveryChannelConfigsResult' GetOutcome() is not any of GetDeliveryChannelConfigsOutcome.[GotDeliveryChannelConfigsWithNoFailuresReported|GetAudienceOutcome.GotDeliveryChannelConfigsWithReportedFailuresIgnored]",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <PreparedToSendOnSomeChannelsEvent>();

                    var result = new PreparedToSendOnSomeChannelsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        referenceObject.GetAudienceResult,
                        A.Dummy <GetDeliveryChannelConfigsResult>().Whose(_ => (_.GetOutcome() != GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithNoFailuresReported) && (_.GetOutcome() != GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithReportedFailuresIgnored)),
                        referenceObject.PrepareToSendNotificationResult);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "getDeliveryChannelConfigsOutcome", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <PreparedToSendOnSomeChannelsEvent>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'prepareToSendNotificationResult' GetOutcome() is is not PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <PreparedToSendOnSomeChannelsEvent>();

                    var result = new PreparedToSendOnSomeChannelsEvent(
                        referenceObject.Id,
                        referenceObject.TimestampUtc,
                        referenceObject.GetAudienceResult,
                        referenceObject.GetDeliveryChannelConfigsResult,
                        A.Dummy <PrepareToSendNotificationResult>().Whose(_ => _.GetOutcome() != PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels));

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "prepareToSendNotificationOutcome" },
            });
        }
コード例 #28
0
 static IdentifiedTypeTest()
 {
     ConstructorArgumentValidationTestScenarios
     .AddScenario(ConstructorArgumentValidationTestScenario <IdentifiedType> .ConstructorCannotThrowScenario);
 }