11using AniWorldReminder_API . Interfaces ;
22using AniWorldReminder_API . Services ;
33using Microsoft . Extensions . Logging . Abstractions ;
4+ using NUnit . Framework ;
45using System . Net ;
56using Telegram . Bot . Types ;
67using Telegram . Bot . Types . Enums ;
78using Telegram . Bot . Types . ReplyMarkups ;
8- using Xunit ;
99
1010namespace AniWorldReminder_API . Tests . Services
1111{
1212 public class AdminHttpFailureNotificationHandlerTests
1313 {
14- [ Fact ]
14+ [ Test ]
1515 public async Task SendAsync_SendsAdminTelegramMessage_OnTransientHttpFailureResponse ( )
1616 {
1717 using CurrentDirectoryScope _ = CurrentDirectoryScope . CreateWithSettingsFile ( adminChat : "123456" ) ;
@@ -24,15 +24,15 @@ public async Task SendAsync_SendsAdminTelegramMessage_OnTransientHttpFailureResp
2424 new HttpRequestMessage ( HttpMethod . Get , "https://example.com/episodes" ) ,
2525 CancellationToken . None ) ;
2626
27- Assert . Equal ( HttpStatusCode . InternalServerError , response . StatusCode ) ;
28- Assert . Single ( telegramBotService . Messages ) ;
29- Assert . Equal ( 123456L , telegramBotService . Messages [ 0 ] . ChatId ) ;
30- Assert . Contains ( "HTTP request failed after all retries" , telegramBotService . Messages [ 0 ] . Text ) ;
31- Assert . Contains ( "GET https://example.com/episodes" , telegramBotService . Messages [ 0 ] . Text ) ;
32- Assert . Contains ( "HTTP 500 InternalServerError" , telegramBotService . Messages [ 0 ] . Text ) ;
27+ Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . InternalServerError ) ) ;
28+ Assert . That ( telegramBotService . Messages , Has . Count . EqualTo ( 1 ) ) ;
29+ Assert . That ( telegramBotService . Messages [ 0 ] . ChatId , Is . EqualTo ( 123456L ) ) ;
30+ Assert . That ( telegramBotService . Messages [ 0 ] . Text , Does . Contain ( "HTTP request failed after all retries" ) ) ;
31+ Assert . That ( telegramBotService . Messages [ 0 ] . Text , Does . Contain ( "GET https://example.com/episodes" ) ) ;
32+ Assert . That ( telegramBotService . Messages [ 0 ] . Text , Does . Contain ( "HTTP 500 InternalServerError" ) ) ;
3333 }
3434
35- [ Fact ]
35+ [ Test ]
3636 public async Task SendAsync_DoesNotSendAdminTelegramMessage_OnSuccessfulResponse ( )
3737 {
3838 using CurrentDirectoryScope _ = CurrentDirectoryScope . CreateWithSettingsFile ( adminChat : "123456" ) ;
@@ -45,11 +45,11 @@ public async Task SendAsync_DoesNotSendAdminTelegramMessage_OnSuccessfulResponse
4545 new HttpRequestMessage ( HttpMethod . Get , "https://example.com/episodes" ) ,
4646 CancellationToken . None ) ;
4747
48- Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
49- Assert . Empty ( telegramBotService . Messages ) ;
48+ Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . OK ) ) ;
49+ Assert . That ( telegramBotService . Messages , Is . Empty ) ;
5050 }
5151
52- [ Fact ]
52+ [ Test ]
5353 public async Task SendAsync_SendsAdminTelegramMessage_OnTransientHttpException ( )
5454 {
5555 using CurrentDirectoryScope _ = CurrentDirectoryScope . CreateWithSettingsFile ( adminChat : "123456" ) ;
@@ -58,13 +58,13 @@ public async Task SendAsync_SendsAdminTelegramMessage_OnTransientHttpException()
5858 telegramBotService ,
5959 new StubHttpMessageHandler ( _ => throw new HttpRequestException ( "network down" ) ) ) ;
6060
61- HttpRequestException exception = await Assert . ThrowsAsync < HttpRequestException > ( ( ) => invoker . SendAsync (
61+ HttpRequestException exception = Assert . ThrowsAsync < HttpRequestException > ( ( ) => invoker . SendAsync (
6262 new HttpRequestMessage ( HttpMethod . Get , "https://example.com/episodes" ) ,
63- CancellationToken . None ) ) ;
63+ CancellationToken . None ) ) ! ;
6464
65- Assert . Equal ( "network down" , exception . Message ) ;
66- Assert . Single ( telegramBotService . Messages ) ;
67- Assert . Contains ( "network down" , telegramBotService . Messages [ 0 ] . Text ) ;
65+ Assert . That ( exception . Message , Is . EqualTo ( "network down" ) ) ;
66+ Assert . That ( telegramBotService . Messages , Has . Count . EqualTo ( 1 ) ) ;
67+ Assert . That ( telegramBotService . Messages [ 0 ] . Text , Does . Contain ( "network down" ) ) ;
6868 }
6969
7070 private static HttpMessageInvoker CreateInvoker ( ITelegramBotService telegramBotService , HttpMessageHandler innerHandler )
0 commit comments