Example #1
0
        private async Task PutCannotGetOrUseDeliveryChannelConfigsEventAsync(
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult,
            long trackingCodeId,
            IReadOnlyCollection <NamedValue <string> > inheritableTags)
        {
            var @event = new CouldNotGetOrUseDeliveryChannelConfigsEvent(trackingCodeId, DateTime.UtcNow, getAudienceResult, getDeliveryChannelConfigsResult);

            var tags = this.buildCouldNotGetOrUseDeliveryChannelConfigsEventTagsProtocol.ExecuteBuildTags(trackingCodeId, @event, inheritableTags);

            await this.eventStream.PutWithIdAsync(trackingCodeId, @event, tags, ExistingRecordStrategy.DoNotWriteIfFoundByIdAndType);
        }
Example #2
0
        private async Task <GetDeliveryChannelConfigsResult> GetDeliveryChannelConfigsAsync(
            INotification notification,
            IAudience audience)
        {
            GetDeliveryChannelConfigsResult result;

            try
            {
                var getDeliveryChannelConfigsOp = new GetDeliveryChannelConfigsOp(notification, audience);

                result = await this.getDeliveryChannelConfigsProtocol.ExecuteAsync(getDeliveryChannelConfigsOp);

                result.AsOp().Must().NotBeNull(Invariant($"Executing {nameof(GetDeliveryChannelConfigsOp)} should not return null."));
            }
            catch (Exception ex)
            {
                result = new GetDeliveryChannelConfigsResult(null, new[] { new ExceptionThrownFailure(ex.ToString()) }, FailureAction.Stop);
            }

            return(result);
        }
            public async Task <GetDeliveryChannelConfigsResult> ExecuteAsync(
                GetDeliveryChannelConfigsOp operation)
            {
                new { operation }.AsArg().Must().NotBeNull();
                new { operation.Notification }.AsArg().Must().NotBeNull().And().BeOfType <IntegrationTestNotification>();
                new { operation.Audience }.AsArg().Must().NotBeNull().And().BeOfType <IntegrationTestAudience>();

                var getDeliveryChannelConfigsResult = new GetDeliveryChannelConfigsResult(
                    new[]
                {
                    new DeliveryChannelConfig(new EmailDeliveryChannel(), DeliveryChannelAction.SendOnChannel),
                    new DeliveryChannelConfig(new SlackDeliveryChannel(), DeliveryChannelAction.SendOnChannel),
                },
                    new[]
                {
                    new ExceptionThrownFailure("exception-thrown-get-delivery-channel-configs"),
                },
                    FailureAction.IgnoreAndProceedIfPossibleOtherwiseStop);

                var result = await Task.FromResult(getDeliveryChannelConfigsResult);

                return(result);
            }
Example #4
0
        private async Task PutPrepareToSendNotificationEventAsync(
            PrepareToSendNotificationOutcome prepareToSendNotificationOutcome,
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult,
            PrepareToSendNotificationResult prepareToSendNotificationResult,
            long trackingCodeId,
            IReadOnlyCollection <NamedValue <string> > inheritableTags)
        {
            PrepareToSendNotificationEventBase @event;

            switch (prepareToSendNotificationOutcome)
            {
            case PrepareToSendNotificationOutcome.AudienceOptedOutOfAllChannels:
                @event = new AudienceOptedOutOfAllChannelsEvent(trackingCodeId, DateTime.UtcNow, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult);
                break;

            case PrepareToSendNotificationOutcome.PreparedToSendOnAllChannels:
                @event = new PreparedToSendOnAllChannelsEvent(trackingCodeId, DateTime.UtcNow, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult);
                break;

            case PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels:
                @event = new PreparedToSendOnSomeChannelsEvent(trackingCodeId, DateTime.UtcNow, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult);
                break;

            case PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelDespiteAttemptingAll:
            case PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelBecauseOneForcedAllToBeDiscarded:
                @event = new CouldNotPrepareToSendOnAnyChannelEvent(trackingCodeId, DateTime.UtcNow, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult);
                break;

            default:
                throw new NotSupportedException(Invariant($"This {nameof(PrepareToSendNotificationOutcome)} is not supported: {prepareToSendNotificationOutcome}"));
            }

            var tags = this.buildPrepareToSendNotificationEventTagsProtocol.ExecuteBuildTags(trackingCodeId, @event, inheritableTags);

            await this.eventStream.PutWithIdAsync(trackingCodeId, @event, tags, ExistingRecordStrategy.DoNotWriteIfFoundByIdAndType);
        }
        static GetDeliveryChannelConfigsResultTest()
        {
            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GetDeliveryChannelConfigsResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'configs' is not null and contains a null element scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <GetDeliveryChannelConfigsResult>();

                    var result = new GetDeliveryChannelConfigsResult(
                        new[] { A.Dummy <DeliveryChannelConfig>(), null, A.Dummy <DeliveryChannelConfig>() },
                        referenceObject.Failures,
                        referenceObject.FailureAction);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "configs", "contains at least one null element", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GetDeliveryChannelConfigsResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'configs' contains duplicate delivery channels",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <GetDeliveryChannelConfigsResult>();

                    var result = new GetDeliveryChannelConfigsResult(
                        new[]
                    {
                        new DeliveryChannelConfig(new EmailDeliveryChannel(), DeliveryChannelAction.SendOnChannel),
                        new DeliveryChannelConfig(new SlackDeliveryChannel(), DeliveryChannelAction.AudienceOptedOut),
                        new DeliveryChannelConfig(new EmailDeliveryChannel(), DeliveryChannelAction.SendOnChannel),
                    },
                        referenceObject.Failures,
                        referenceObject.FailureAction);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "deliveryChannels", "contains two or more elements that are equal", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GetDeliveryChannelConfigsResult>
            {
                Name             = "constructor should throw ArgumentException when parameter 'failures' is not null and contains a null element scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <GetDeliveryChannelConfigsResult>();

                    var result = new GetDeliveryChannelConfigsResult(
                        referenceObject.Configs,
                        new[] { A.Dummy <IFailure>(), null, A.Dummy <IFailure>() },
                        referenceObject.FailureAction);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "failures", "contains at least one null element", },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <GetDeliveryChannelConfigsResult>
            {
                Name             = "constructor should throw ArgumentOutOfRangeException when parameter 'failureAction' is FailureAction.Unknown",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <GetDeliveryChannelConfigsResult>();

                    var result = new GetDeliveryChannelConfigsResult(
                        referenceObject.Configs,
                        referenceObject.Failures,
                        FailureAction.Unknown);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentOutOfRangeException),
                ExpectedExceptionMessageContains = new[] { "failureAction", "Unknown", },
            });
        }
Example #6
0
        public NotificationDummyFactory()
        {
            /* Add any overriding or custom registrations here. */

            // enums
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(CannotPrepareToSendOnChannelAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(DeliveryChannelAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(FailureAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(PrepareToSendOnChannelFailureAction.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(AttemptToSendNotificationOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(ChannelOperationOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(GetAudienceOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(GetDeliveryChannelConfigsOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(PrepareToSendNotificationOutcome.Unknown);
            AutoFixtureBackedDummyFactory.ConstrainDummyToExclude(PrepareToSendOnChannelOutcome.Unknown);

            // interfaces
            AutoFixtureBackedDummyFactory.AddDummyCreator <IOperation>(A.Dummy <OperationBase>);// remove when moved to Protocol Dummy Factory
            AutoFixtureBackedDummyFactory.UseRandomInterfaceImplementationForDummy <IAudience>();
            AutoFixtureBackedDummyFactory.UseRandomInterfaceImplementationForDummy <IDeliveryChannel>();
            AutoFixtureBackedDummyFactory.UseRandomInterfaceImplementationForDummy <IFailure>();
            AutoFixtureBackedDummyFactory.UseRandomInterfaceImplementationForDummy <INotification>();

            // events
            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new CouldNotSendOnAnyPreparedChannelEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              A.Dummy <AttemptToSendNotificationResult>().Whose(_ => _.GetOutcome() == AttemptToSendNotificationOutcome.CouldNotSendOnAnyPreparedChannel)));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new SentOnAllPreparedChannelsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              A.Dummy <AttemptToSendNotificationResult>().Whose(_ => _.GetOutcome() == AttemptToSendNotificationOutcome.SentOnAllPreparedChannels)));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new SentOnSomePreparedChannelsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              A.Dummy <AttemptToSendNotificationResult>().Whose(_ => _.GetOutcome() == AttemptToSendNotificationOutcome.SentOnSomePreparedChannels)));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new CouldNotGetOrUseAudienceEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              A.Dummy <GetAudienceResult>().Whose(_ => (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithNoFailuresReported) && (_.GetOutcome() != GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new CouldNotGetOrUseDeliveryChannelConfigsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              GetPassingAudienceResult(),
                                                              A.Dummy <GetDeliveryChannelConfigsResult>().Whose(_ => (_.GetOutcome() != GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithNoFailuresReported) && (_.GetOutcome() != GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithReportedFailuresIgnored))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new AudienceOptedOutOfAllChannelsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              GetPassingAudienceResult(),
                                                              GetPassingDeliveryChannelConfigsResult(),
                                                              A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (_.GetOutcome() == PrepareToSendNotificationOutcome.AudienceOptedOutOfAllChannels))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new CouldNotPrepareToSendOnAnyChannelEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              GetPassingAudienceResult(),
                                                              GetPassingDeliveryChannelConfigsResult(),
                                                              A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (_.GetOutcome() == PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelDespiteAttemptingAll) || (_.GetOutcome() == PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelBecauseOneForcedAllToBeDiscarded))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new PreparedToSendOnAllChannelsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              GetPassingAudienceResult(),
                                                              GetPassingDeliveryChannelConfigsResult(),
                                                              A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (_.GetOutcome() == PrepareToSendNotificationOutcome.PreparedToSendOnAllChannels))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new PreparedToSendOnSomeChannelsEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              GetPassingAudienceResult(),
                                                              GetPassingDeliveryChannelConfigsResult(),
                                                              A.Dummy <PrepareToSendNotificationResult>().Whose(_ => (_.GetOutcome() == PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels))));

            AutoFixtureBackedDummyFactory.AddDummyCreator(() => new SendNotificationRequestedEvent(
                                                              A.Dummy <long>(),
                                                              A.Dummy <UtcDateTime>(),
                                                              A.Dummy <SendNotificationOp>()));

            // model classes
            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var channelToOperationsOutcomeInfoMap = new Dictionary <IDeliveryChannel, IReadOnlyCollection <ChannelOperationOutcomeInfo> >();

                var randomIndex = ThreadSafeRandom.Next(1, 4);

                var randomChannels = new IDeliveryChannel[] { new SlackDeliveryChannel(), new EmailDeliveryChannel() }.RandomizeElements().ToArray();

                if (randomIndex == 1)
                {
                    // SentOnAllPreparedChannels
                    randomChannels = randomChannels.Take(ThreadSafeRandom.Next(1, randomChannels.Length + 1)).ToArray();

                    foreach (var randomChannel in randomChannels)
                    {
                        channelToOperationsOutcomeInfoMap.Add(
                            randomChannel,
                            Some.ReadOnlyDummies <ChannelOperationOutcomeInfo>().Whose(_ => _.All(o => o.Outcome == ChannelOperationOutcome.Succeeded)).ToList());
                    }
                }
                else if (randomIndex == 2)
                {
                    // SentOnSomePreparedChannels
                    channelToOperationsOutcomeInfoMap.Add(
                        randomChannels[0],
                        Some.ReadOnlyDummies <ChannelOperationOutcomeInfo>().Whose(_ => _.Select(o => o.Outcome).Distinct().Count() > 1).ToList());

                    channelToOperationsOutcomeInfoMap.Add(
                        randomChannels[1],
                        Some.ReadOnlyDummies <ChannelOperationOutcomeInfo>().Whose(_ => _.All(o => o.Outcome == ChannelOperationOutcome.Succeeded)).ToList());
                }
                else
                {
                    // CouldNotSendOnAnyPreparedChannel
                    channelToOperationsOutcomeInfoMap.Add(
                        randomChannels[0],
                        Some.ReadOnlyDummies <ChannelOperationOutcomeInfo>().Whose(_ => _.Select(o => o.Outcome).Distinct().Count() > 1).ToList());

                    channelToOperationsOutcomeInfoMap.Add(
                        randomChannels[1],
                        Some.ReadOnlyDummies <ChannelOperationOutcomeInfo>().Whose(_ => _.All(o => o.Outcome == ChannelOperationOutcome.Failed)).ToList());
                }


                var result = new AttemptToSendNotificationResult(channelToOperationsOutcomeInfoMap);

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var randomIndex = ThreadSafeRandom.Next(1, 6);

                GetAudienceResult result;

                if (randomIndex == 1)
                {
                    // GotAudienceWithNoFailuresReported
                    result = new GetAudienceResult(A.Dummy <IAudience>(), null, A.Dummy <FailureAction>());
                }
                else if (randomIndex == 2)
                {
                    // GotAudienceWithReportedFailuresIgnored
                    result = new GetAudienceResult(A.Dummy <IAudience>(), Some.ReadOnlyDummies <IFailure>().ToList(), FailureAction.IgnoreAndProceedIfPossibleOtherwiseStop);
                }
                else if (randomIndex == 3)
                {
                    // CouldNotGetAudienceAndNoFailuresReported
                    if (ThreadSafeRandom.Next(2) == 0)
                    {
                        result = new GetAudienceResult(null, null, A.Dummy <FailureAction>());
                    }
                    else
                    {
                        result = new GetAudienceResult(null, new IFailure[0], A.Dummy <FailureAction>());
                    }
                }
                else if (randomIndex == 4)
                {
                    // CouldNotGetAudienceWithSomeFailuresReported
                    result = new GetAudienceResult(null, Some.ReadOnlyDummies <IFailure>().ToList(), A.Dummy <FailureAction>());
                }
                else
                {
                    // DespiteGettingAudienceFailuresPreventUsingIt
                    result = new GetAudienceResult(A.Dummy <IAudience>(), Some.ReadOnlyDummies <IFailure>().ToList(), FailureAction.Stop);
                }

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var randomChannels = new IDeliveryChannel[] { new SlackDeliveryChannel(), new EmailDeliveryChannel() };

                randomChannels = randomChannels.RandomizeElements().Take(ThreadSafeRandom.Next(1, randomChannels.Length + 1)).ToArray();

                var deliveryChannelConfigs = randomChannels.Select(_ => new DeliveryChannelConfig(_, A.Dummy <DeliveryChannelAction>())).ToList();

                var randomIndex = ThreadSafeRandom.Next(1, 6);

                GetDeliveryChannelConfigsResult result;

                if (randomIndex == 1)
                {
                    // GotDeliveryChannelConfigsWithNoFailuresReported
                    result = new GetDeliveryChannelConfigsResult(
                        deliveryChannelConfigs,
                        null,
                        A.Dummy <FailureAction>());
                }
                else if (randomIndex == 2)
                {
                    // GotDeliveryChannelConfigsWithReportedFailuresIgnored
                    result = new GetDeliveryChannelConfigsResult(
                        deliveryChannelConfigs,
                        Some.ReadOnlyDummies <IFailure>().ToList(),
                        FailureAction.IgnoreAndProceedIfPossibleOtherwiseStop);
                }
                else if (randomIndex == 3)
                {
                    // CouldNotGetDeliveryChannelConfigsAndNoFailuresReported
                    result = new GetDeliveryChannelConfigsResult(null, null, A.Dummy <FailureAction>());
                }
                else if (randomIndex == 4)
                {
                    // CouldNotGetDeliveryChannelConfigsWithSomeFailuresReported
                    result = new GetDeliveryChannelConfigsResult(null, Some.ReadOnlyDummies <IFailure>().ToList(), A.Dummy <FailureAction>());
                }
                else
                {
                    // DespiteGettingDeliveryChannelConfigsFailuresPreventUsingThem
                    result = new GetDeliveryChannelConfigsResult(
                        deliveryChannelConfigs,
                        Some.ReadOnlyDummies <IFailure>().ToList(),
                        FailureAction.Stop);
                }

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var randomChannels = new IDeliveryChannel[] { new SlackDeliveryChannel(), new EmailDeliveryChannel() }.RandomizeElements().ToArray();

                var randomIndex = ThreadSafeRandom.Next(1, 6);

                PrepareToSendNotificationResult result;

                if (randomIndex == 1)
                {
                    // AudienceOptedOutOfAllChannels
                    result = new PrepareToSendNotificationResult(
                        new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult>(),
                        A.Dummy <CannotPrepareToSendOnChannelAction>(),
                        new IDeliveryChannel[0]);
                }
                else if (randomIndex == 2)
                {
                    // PreparedToSendOnAllChannels
                    var channelToPrepareToSendOnChannelResultMap = new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult>();

                    foreach (var randomChannel in randomChannels)
                    {
                        channelToPrepareToSendOnChannelResultMap.Add(
                            randomChannel,
                            new PrepareToSendOnChannelResult(GetChannelOperationInstructions(), null, A.Dummy <PrepareToSendOnChannelFailureAction>()));
                    }

                    result = new PrepareToSendNotificationResult(
                        channelToPrepareToSendOnChannelResultMap,
                        A.Dummy <CannotPrepareToSendOnChannelAction>(),
                        randomChannels);
                }
                else if (randomIndex == 3)
                {
                    // PreparedToSendOnSomeChannels
                    result = new PrepareToSendNotificationResult(
                        new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult>
                    {
                        {
                            randomChannels[0],
                            new PrepareToSendOnChannelResult(
                                GetChannelOperationInstructions(),
                                Some.ReadOnlyDummies <IFailure>().ToList(),
                                PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel)
                        },
                        {
                            randomChannels[1],
                            new PrepareToSendOnChannelResult(
                                null,
                                null,
                                PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel)
                        },
                    },
                        CannotPrepareToSendOnChannelAction.ContinueAndAttemptPreparingToSendOnNextChannel,
                        new IDeliveryChannel[] { randomChannels[0] });
                }
                else if (randomIndex == 4)
                {
                    // CouldNotPrepareToSendOnAnyChannelDespiteAttemptingAll
                    result = new PrepareToSendNotificationResult(
                        new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult>
                    {
                        {
                            new SlackDeliveryChannel(),
                            new PrepareToSendOnChannelResult(
                                null,
                                null,
                                PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel)
                        },
                        {
                            new EmailDeliveryChannel(),
                            new PrepareToSendOnChannelResult(
                                GetChannelOperationInstructions(),
                                Some.ReadOnlyDummies <IFailure>().ToList(),
                                PrepareToSendOnChannelFailureAction.DoNotSendOnChannel)
                        },
                    },
                        CannotPrepareToSendOnChannelAction.ContinueAndAttemptPreparingToSendOnNextChannel,
                        new IDeliveryChannel[0]);
                }
                else
                {
                    // CouldNotPrepareToSendOnAnyChannelBecauseOneForcedAllToBeDiscarded
                    result = new PrepareToSendNotificationResult(
                        new Dictionary <IDeliveryChannel, PrepareToSendOnChannelResult>
                    {
                        {
                            randomChannels[0],
                            new PrepareToSendOnChannelResult(
                                GetChannelOperationInstructions(),
                                Some.ReadOnlyDummies <IFailure>().ToList(),
                                PrepareToSendOnChannelFailureAction.DoNotSendOnChannel)
                        },
                    },
                        CannotPrepareToSendOnChannelAction.StopAndNotDoNotSendOnAnyChannel,
                        new IDeliveryChannel[0]);
                }

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var randomIndex = ThreadSafeRandom.Next(1, 6);

                PrepareToSendOnChannelResult result;

                if (randomIndex == 1)
                {
                    // PreparedToSendOnChannelWithNoFailuresReported
                    result = new PrepareToSendOnChannelResult(
                        GetChannelOperationInstructions(),
                        null,
                        A.Dummy <PrepareToSendOnChannelFailureAction>());
                }
                else if (randomIndex == 2)
                {
                    // PreparedToSendOnChannelWithReportedFailuresIgnored
                    result = new PrepareToSendOnChannelResult(
                        GetChannelOperationInstructions(),
                        Some.ReadOnlyDummies <IFailure>().ToList(),
                        PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel);
                }
                else if (randomIndex == 3)
                {
                    // CouldNotPrepareToSendOnChannelAndNoFailuresReported
                    if (ThreadSafeRandom.Next(2) == 0)
                    {
                        result = new PrepareToSendOnChannelResult(
                            null,
                            null,
                            PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel);
                    }
                    else
                    {
                        result = new PrepareToSendOnChannelResult(
                            new ChannelOperationInstruction[0],
                            new IFailure[0],
                            PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel);
                    }
                }
                else if (randomIndex == 4)
                {
                    // CouldNotPrepareToSendOnChannelWithSomeFailuresReported
                    result = new PrepareToSendOnChannelResult(
                        null,
                        Some.ReadOnlyDummies <IFailure>().ToList(),
                        PrepareToSendOnChannelFailureAction.IgnoreAndProceedIfPossibleOtherwiseDoNotSendOnChannel);
                }
                else
                {
                    // DespitePreparingToSendOnChannelFailuresPreventUsingIt
                    result = new PrepareToSendOnChannelResult(
                        GetChannelOperationInstructions(),
                        Some.ReadOnlyDummies <IFailure>().ToList(),
                        PrepareToSendOnChannelFailureAction.DoNotSendOnChannel);
                }

                return(result);
            });

            AutoFixtureBackedDummyFactory.AddDummyCreator(() =>
            {
                var succeededEventType = A.Dummy <TypeRepresentation>();

                var failedEventType = A.Dummy <TypeRepresentation>().ThatIsNot(succeededEventType);

                var result = new ChannelOperationMonitoringInfo(A.Dummy <long>(), succeededEventType, failedEventType);

                return(result);
            });
        }