@@ -142,6 +142,58 @@ await messagingDomainService.ResendEmailMessage(TestData.ConnectionIdentifier,
142142 CancellationToken . None ) ;
143143 }
144144
145+ [ Fact ]
146+ public async Task MessagingDomainService_ResendEmailMessage_APICallFailed_MessageFailed ( )
147+ {
148+ Mock < IAggregateRepository < EmailAggregate , DomainEvent > > emailAggregateRepository = new Mock < IAggregateRepository < EmailAggregate , DomainEvent > > ( ) ;
149+ emailAggregateRepository . Setup ( a => a . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetSentEmailAggregate ) ;
150+ Mock < IAggregateRepository < SMSAggregate , DomainEvent > > smsAggregateRepository = new Mock < IAggregateRepository < SMSAggregate , DomainEvent > > ( ) ;
151+ Mock < IEmailServiceProxy > emailServiceProxy = new Mock < IEmailServiceProxy > ( ) ;
152+ emailServiceProxy
153+ . Setup ( e => e . SendEmail ( It . IsAny < Guid > ( ) ,
154+ It . IsAny < String > ( ) ,
155+ It . IsAny < List < String > > ( ) ,
156+ It . IsAny < String > ( ) ,
157+ It . IsAny < String > ( ) ,
158+ It . IsAny < Boolean > ( ) ,
159+ It . IsAny < List < EmailAttachment > > ( ) ,
160+ It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . FailedAPICallEmailServiceProxyResponse ) ;
161+ Mock < ISMSServiceProxy > smsServiceProxy = new Mock < ISMSServiceProxy > ( ) ;
162+
163+ MessagingDomainService messagingDomainService =
164+ new MessagingDomainService ( emailAggregateRepository . Object , smsAggregateRepository . Object , emailServiceProxy . Object , smsServiceProxy . Object ) ;
165+
166+ await messagingDomainService . ResendEmailMessage ( TestData . ConnectionIdentifier ,
167+ TestData . MessageId ,
168+ CancellationToken . None ) ;
169+ }
170+
171+ [ Fact ]
172+ public async Task MessagingDomainService_ResendEmailMessage_APIResponseError_MessageFailed ( )
173+ {
174+ Mock < IAggregateRepository < EmailAggregate , DomainEvent > > emailAggregateRepository = new Mock < IAggregateRepository < EmailAggregate , DomainEvent > > ( ) ;
175+ emailAggregateRepository . Setup ( a => a . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetSentEmailAggregate ) ;
176+ Mock < IAggregateRepository < SMSAggregate , DomainEvent > > smsAggregateRepository = new Mock < IAggregateRepository < SMSAggregate , DomainEvent > > ( ) ;
177+ Mock < IEmailServiceProxy > emailServiceProxy = new Mock < IEmailServiceProxy > ( ) ;
178+ emailServiceProxy
179+ . Setup ( e => e . SendEmail ( It . IsAny < Guid > ( ) ,
180+ It . IsAny < String > ( ) ,
181+ It . IsAny < List < String > > ( ) ,
182+ It . IsAny < String > ( ) ,
183+ It . IsAny < String > ( ) ,
184+ It . IsAny < Boolean > ( ) ,
185+ It . IsAny < List < EmailAttachment > > ( ) ,
186+ It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . FailedEmailServiceProxyResponse ) ;
187+ Mock < ISMSServiceProxy > smsServiceProxy = new Mock < ISMSServiceProxy > ( ) ;
188+
189+ MessagingDomainService messagingDomainService =
190+ new MessagingDomainService ( emailAggregateRepository . Object , smsAggregateRepository . Object , emailServiceProxy . Object , smsServiceProxy . Object ) ;
191+
192+ await messagingDomainService . ResendEmailMessage ( TestData . ConnectionIdentifier ,
193+ TestData . MessageId ,
194+ CancellationToken . None ) ;
195+ }
196+
145197 [ Fact ]
146198 public async Task MessagingDomainService_SendSMSMessage_MessageSent ( )
147199 {
@@ -167,5 +219,71 @@ await messagingDomainService.SendSMSMessage(TestData.ConnectionIdentifier,
167219 CancellationToken . None ) ;
168220 }
169221
222+ [ Fact ]
223+ public async Task MessagingDomainService_ReSendSMSMessage_MessageSent ( )
224+ {
225+ Mock < IAggregateRepository < EmailAggregate , DomainEvent > > emailAggregateRepository = new Mock < IAggregateRepository < EmailAggregate , DomainEvent > > ( ) ;
226+ Mock < IAggregateRepository < SMSAggregate , DomainEvent > > smsAggregateRepository = new Mock < IAggregateRepository < SMSAggregate , DomainEvent > > ( ) ;
227+ smsAggregateRepository . Setup ( a => a . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetSentSMSAggregate ) ;
228+ Mock < IEmailServiceProxy > emailServiceProxy = new Mock < IEmailServiceProxy > ( ) ;
229+ Mock < ISMSServiceProxy > smsServiceProxy = new Mock < ISMSServiceProxy > ( ) ;
230+ smsServiceProxy
231+ . Setup ( e => e . SendSMS ( It . IsAny < Guid > ( ) ,
232+ It . IsAny < String > ( ) ,
233+ It . IsAny < String > ( ) ,
234+ It . IsAny < String > ( ) ,
235+ It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . SuccessfulSMSServiceProxyResponse ) ;
236+ MessagingDomainService messagingDomainService =
237+ new MessagingDomainService ( emailAggregateRepository . Object , smsAggregateRepository . Object , emailServiceProxy . Object , smsServiceProxy . Object ) ;
238+
239+ await messagingDomainService . ResendSMSMessage ( TestData . ConnectionIdentifier ,
240+ TestData . MessageId ,
241+ CancellationToken . None ) ;
242+ }
243+
244+ [ Fact ]
245+ public async Task MessagingDomainService_ReSendSMSMessage_APICallFailed_MessageFailed ( )
246+ {
247+ Mock < IAggregateRepository < EmailAggregate , DomainEvent > > emailAggregateRepository = new Mock < IAggregateRepository < EmailAggregate , DomainEvent > > ( ) ;
248+ Mock < IAggregateRepository < SMSAggregate , DomainEvent > > smsAggregateRepository = new Mock < IAggregateRepository < SMSAggregate , DomainEvent > > ( ) ;
249+ smsAggregateRepository . Setup ( a => a . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetSentSMSAggregate ) ;
250+ Mock < IEmailServiceProxy > emailServiceProxy = new Mock < IEmailServiceProxy > ( ) ;
251+ Mock < ISMSServiceProxy > smsServiceProxy = new Mock < ISMSServiceProxy > ( ) ;
252+ smsServiceProxy
253+ . Setup ( e => e . SendSMS ( It . IsAny < Guid > ( ) ,
254+ It . IsAny < String > ( ) ,
255+ It . IsAny < String > ( ) ,
256+ It . IsAny < String > ( ) ,
257+ It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . FailedAPICallSMSServiceProxyResponse ) ;
258+ MessagingDomainService messagingDomainService =
259+ new MessagingDomainService ( emailAggregateRepository . Object , smsAggregateRepository . Object , emailServiceProxy . Object , smsServiceProxy . Object ) ;
260+
261+ await messagingDomainService . ResendSMSMessage ( TestData . ConnectionIdentifier ,
262+ TestData . MessageId ,
263+ CancellationToken . None ) ;
264+ }
265+
266+ [ Fact ]
267+ public async Task MessagingDomainService_ReSendSMSMessage_APIResponseError_MessageFailed ( )
268+ {
269+ Mock < IAggregateRepository < EmailAggregate , DomainEvent > > emailAggregateRepository = new Mock < IAggregateRepository < EmailAggregate , DomainEvent > > ( ) ;
270+ Mock < IAggregateRepository < SMSAggregate , DomainEvent > > smsAggregateRepository = new Mock < IAggregateRepository < SMSAggregate , DomainEvent > > ( ) ;
271+ smsAggregateRepository . Setup ( a => a . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetSentSMSAggregate ) ;
272+ Mock < IEmailServiceProxy > emailServiceProxy = new Mock < IEmailServiceProxy > ( ) ;
273+ Mock < ISMSServiceProxy > smsServiceProxy = new Mock < ISMSServiceProxy > ( ) ;
274+ smsServiceProxy
275+ . Setup ( e => e . SendSMS ( It . IsAny < Guid > ( ) ,
276+ It . IsAny < String > ( ) ,
277+ It . IsAny < String > ( ) ,
278+ It . IsAny < String > ( ) ,
279+ It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . FailedSMSServiceProxyResponse ) ;
280+ MessagingDomainService messagingDomainService =
281+ new MessagingDomainService ( emailAggregateRepository . Object , smsAggregateRepository . Object , emailServiceProxy . Object , smsServiceProxy . Object ) ;
282+
283+ await messagingDomainService . ResendSMSMessage ( TestData . ConnectionIdentifier ,
284+ TestData . MessageId ,
285+ CancellationToken . None ) ;
286+ }
287+
170288 }
171289}
0 commit comments