Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PreparedToSendOnSomeChannelsEvent"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="getAudienceResult">The result of executing a <see cref="GetAudienceOp"/>.</param>
        /// <param name="getDeliveryChannelConfigsResult">The result of executing a <see cref="GetDeliveryChannelConfigsOp"/>.</param>
        /// <param name="prepareToSendNotificationResult">The result of preparing to send the notification on all configured channels.</param>
        public PreparedToSendOnSomeChannelsEvent(
            long id,
            DateTime timestampUtc,
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult,
            PrepareToSendNotificationResult prepareToSendNotificationResult)
            : base(id, timestampUtc, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult)
        {
            var prepareToSendNotificationOutcome = prepareToSendNotificationResult.GetOutcome();

            new { prepareToSendNotificationOutcome }.AsArg().Must().BeEqualTo(PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CouldNotPrepareToSendOnAnyChannelEvent"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="getAudienceResult">The result of executing a <see cref="GetAudienceOp"/>.</param>
        /// <param name="getDeliveryChannelConfigsResult">The result of executing a <see cref="GetDeliveryChannelConfigsOp"/>.</param>
        /// <param name="prepareToSendNotificationResult">The result of preparing to send the notification on all configured channels.</param>
        public CouldNotPrepareToSendOnAnyChannelEvent(
            long id,
            DateTime timestampUtc,
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult,
            PrepareToSendNotificationResult prepareToSendNotificationResult)
            : base(id, timestampUtc, getAudienceResult, getDeliveryChannelConfigsResult, prepareToSendNotificationResult)
        {
            var prepareToSendNotificationOutcome = prepareToSendNotificationResult.GetOutcome();

            new { prepareToSendNotificationOutcome }.AsArg().Must().BeElementIn(new[] { PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelBecauseOneForcedAllToBeDiscarded, PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelDespiteAttemptingAll });
        }
        /// <summary>
        /// Summarize a <see cref="GetDeliveryChannelConfigsResult"/> as a <see cref="GetDeliveryChannelConfigsOutcome" />.
        /// </summary>
        /// <param name="getDeliveryChannelConfigsResult">The result of executing a <see cref="GetDeliveryChannelConfigsOp"/>.</param>
        /// <returns>
        /// A <see cref="GetDeliveryChannelConfigsResult"/> summarized as <see cref="GetDeliveryChannelConfigsOutcome"/>.
        /// </returns>
        public static GetDeliveryChannelConfigsOutcome GetOutcome(
            this GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult)
        {
            new { getDeliveryChannelConfigsResult }.AsArg().Must().NotBeNull();

            GetDeliveryChannelConfigsOutcome result;

            if ((getDeliveryChannelConfigsResult.Configs == null) || (!getDeliveryChannelConfigsResult.Configs.Any()))
            {
                if ((getDeliveryChannelConfigsResult.Failures == null) || (!getDeliveryChannelConfigsResult.Failures.Any()))
                {
                    result = GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsAndNoFailuresReported;
                }
                else
                {
                    result = GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsWithSomeFailuresReported;
                }
            }
            else
            {
                if ((getDeliveryChannelConfigsResult.Failures == null) || (!getDeliveryChannelConfigsResult.Failures.Any()))
                {
                    result = GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithNoFailuresReported;
                }
                else
                {
                    if (getDeliveryChannelConfigsResult.FailureAction == FailureAction.Stop)
                    {
                        result = GetDeliveryChannelConfigsOutcome.DespiteGettingDeliveryChannelConfigsFailuresPreventUsingThem;
                    }
                    else if (getDeliveryChannelConfigsResult.FailureAction == FailureAction.IgnoreAndProceedIfPossibleOtherwiseStop)
                    {
                        result = GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithReportedFailuresIgnored;
                    }
                    else
                    {
                        throw new NotSupportedException(Invariant($"This {nameof(FailureAction)} is not supported: {getDeliveryChannelConfigsResult.FailureAction}."));
                    }
                }
            }

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CouldNotGetOrUseDeliveryChannelConfigsEvent"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="getAudienceResult">The result of executing a <see cref="GetAudienceOp"/>.</param>
        /// <param name="getDeliveryChannelConfigsResult">The result of executing a <see cref="GetDeliveryChannelConfigsOp"/>.</param>
        public CouldNotGetOrUseDeliveryChannelConfigsEvent(
            long id,
            DateTime timestampUtc,
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult)
            : base(id, timestampUtc)
        {
            new { getAudienceResult }.AsArg().Must().NotBeNull();
            var getAudienceOutcome = getAudienceResult.GetOutcome();

            new { getAudienceOutcome }.AsArg().Must().BeElementIn(new[] { GetAudienceOutcome.GotAudienceWithNoFailuresReported, GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored });

            new { getDeliveryChannelConfigsResult }.AsArg().Must().NotBeNull();
            var getDeliveryChannelConfigsOutcome = getDeliveryChannelConfigsResult.GetOutcome();

            new { getDeliveryChannelConfigsOutcome }.AsArg().Must().BeElementIn(new[] { GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsAndNoFailuresReported, GetDeliveryChannelConfigsOutcome.CouldNotGetDeliveryChannelConfigsWithSomeFailuresReported, GetDeliveryChannelConfigsOutcome.DespiteGettingDeliveryChannelConfigsFailuresPreventUsingThem });

            this.GetAudienceResult = getAudienceResult;
            this.GetDeliveryChannelConfigsResult = getDeliveryChannelConfigsResult;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PrepareToSendNotificationEventBase"/> class.
        /// </summary>
        /// <param name="id">The notification tracking code identifier.</param>
        /// <param name="timestampUtc">The timestamp in UTC.</param>
        /// <param name="getAudienceResult">The result of executing a <see cref="GetAudienceOp"/>.</param>
        /// <param name="getDeliveryChannelConfigsResult">The result of executing a <see cref="GetDeliveryChannelConfigsOp"/>.</param>
        /// <param name="prepareToSendNotificationResult">The result of preparing to send the notification on all configured channels.</param>
        protected PrepareToSendNotificationEventBase(
            long id,
            DateTime timestampUtc,
            GetAudienceResult getAudienceResult,
            GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult,
            PrepareToSendNotificationResult prepareToSendNotificationResult)
            : base(id, timestampUtc)
        {
            new { getAudienceResult }.AsArg().Must().NotBeNull();
            var getAudienceOutcome = getAudienceResult.GetOutcome();

            new { getAudienceOutcome }.AsArg().Must().BeElementIn(new[] { GetAudienceOutcome.GotAudienceWithNoFailuresReported, GetAudienceOutcome.GotAudienceWithReportedFailuresIgnored });

            new { getDeliveryChannelConfigsResult }.AsArg().Must().NotBeNull();
            var getDeliveryChannelConfigsOutcome = getDeliveryChannelConfigsResult.GetOutcome();

            new { getDeliveryChannelConfigsOutcome }.AsArg().Must().BeElementIn(new[] { GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithNoFailuresReported, GetDeliveryChannelConfigsOutcome.GotDeliveryChannelConfigsWithReportedFailuresIgnored });

            new { prepareToSendNotificationResult }.AsArg().Must().NotBeNull();

            this.GetAudienceResult = getAudienceResult;
            this.GetDeliveryChannelConfigsResult = getDeliveryChannelConfigsResult;
            this.PrepareToSendNotificationResult = prepareToSendNotificationResult;
        }
Esempio n. 6
0
        public override PrepareToSendNotificationEventBase DeepCloneWithGetDeliveryChannelConfigsResult(GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult)
        {
            var result = new PreparedToSendOnAllChannelsEvent(
                this.Id.DeepClone(),
                this.TimestampUtc.DeepClone(),
                this.GetAudienceResult?.DeepClone(),
                getDeliveryChannelConfigsResult,
                this.PrepareToSendNotificationResult?.DeepClone());

            return(result);
        }
 public virtual PrepareToSendNotificationEventBase DeepCloneWithGetDeliveryChannelConfigsResult(GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult)
 {
     throw new NotImplementedException("This method should be abstract.  It was generated as virtual so that you aren't forced to override it when you create a new model that derives from this model.  It will be overridden in the generated designer file.");
 }
        public CouldNotGetOrUseDeliveryChannelConfigsEvent DeepCloneWithGetDeliveryChannelConfigsResult(GetDeliveryChannelConfigsResult getDeliveryChannelConfigsResult)
        {
            var result = new CouldNotGetOrUseDeliveryChannelConfigsEvent(
                this.Id.DeepClone(),
                this.TimestampUtc.DeepClone(),
                this.GetAudienceResult?.DeepClone(),
                getDeliveryChannelConfigsResult);

            return(result);
        }