/// <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="PrepareToSendNotificationResult"/> as a <see cref="PrepareToSendNotificationOutcome" />. /// </summary> /// <param name="prepareToSendNotificationResult">The result of preparing to send a notification on all configured channels.</param> /// <returns> /// A <see cref="PrepareToSendNotificationResult"/> summarized as <see cref="PrepareToSendNotificationOutcome"/>. /// </returns> public static PrepareToSendNotificationOutcome GetOutcome( this PrepareToSendNotificationResult prepareToSendNotificationResult) { new { prepareToSendNotificationResult }.AsArg().Must().NotBeNull(); PrepareToSendNotificationOutcome result; var channelToPrepareToSendOnChannelResultMap = prepareToSendNotificationResult.ChannelToPrepareToSendOnChannelResultMap; var channelsToSendOn = prepareToSendNotificationResult.ChannelsToSendOn; var cannotPrepareToSendOnChannelAction = prepareToSendNotificationResult.CannotPrepareToSendOnChannelAction; if (!channelToPrepareToSendOnChannelResultMap.Any()) { result = PrepareToSendNotificationOutcome.AudienceOptedOutOfAllChannels; } else if (!channelToPrepareToSendOnChannelResultMap.Keys.SymmetricDifference(channelsToSendOn).Any()) { result = PrepareToSendNotificationOutcome.PreparedToSendOnAllChannels; } else if (channelsToSendOn.Any()) { result = PrepareToSendNotificationOutcome.PreparedToSendOnSomeChannels; } else if (cannotPrepareToSendOnChannelAction == CannotPrepareToSendOnChannelAction.StopAndNotDoNotSendOnAnyChannel) { result = PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelBecauseOneForcedAllToBeDiscarded; } else if (cannotPrepareToSendOnChannelAction == CannotPrepareToSendOnChannelAction.ContinueAndAttemptPreparingToSendOnNextChannel) { result = PrepareToSendNotificationOutcome.CouldNotPrepareToSendOnAnyChannelDespiteAttemptingAll; } else { throw new NotSupportedException(Invariant($"This {nameof(CannotPrepareToSendOnChannelAction)} is not supported: {cannotPrepareToSendOnChannelAction}.")); } return(result); }
/// <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; }
public override PrepareToSendNotificationEventBase DeepCloneWithPrepareToSendNotificationResult(PrepareToSendNotificationResult prepareToSendNotificationResult) { var result = new PreparedToSendOnAllChannelsEvent( this.Id.DeepClone(), this.TimestampUtc.DeepClone(), this.GetAudienceResult?.DeepClone(), this.GetDeliveryChannelConfigsResult?.DeepClone(), prepareToSendNotificationResult); return(result); }
public virtual PrepareToSendNotificationEventBase DeepCloneWithPrepareToSendNotificationResult(PrepareToSendNotificationResult prepareToSendNotificationResult) { 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."); }