File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
2+ using SocketLabs . InjectionApi ;
3+ using SocketLabs . InjectionApi . Message ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Net . Http ;
7+ using System . Text ;
8+ using System . Threading ;
9+ using System . Threading . Tasks ;
10+
11+ namespace SocketLabs . InjectionApi . Tests
12+ {
13+ [ TestClass ( ) ]
14+ public class SocketLabsClientTests
15+ {
16+ [ TestMethod ( ) ]
17+ public async Task SendAsyncTest ( )
18+ {
19+ int serverId = 999 ;
20+ string bearerApiKey = "abcdefjhijklmnopqrst.uvwxyzabcdefghijklmnopqrstuvwxyz12345678" ;
21+
22+ var client = new SocketLabsClient ( serverId , bearerApiKey ) ;
23+ client . EndpointUrl = "https://example.local" ;
24+ client . NumberOfRetries = 1 ;
25+
26+ var message = new BasicMessage ( ) ;
27+ message . To . Add ( "test@example.local" ) ;
28+ message . From = new EmailAddress ( "test@example.local" ) ;
29+ message . Subject = "Test" ;
30+ message . HtmlBody = "<p>This is a test!</p>" ;
31+
32+ await Assert . ThrowsExceptionAsync < HttpRequestException > ( async ( ) => await client . SendAsync ( message , CancellationToken . None ) ) ;
33+
34+ // The client should throw the same exception on subsequent calls.
35+ await Assert . ThrowsExceptionAsync < HttpRequestException > ( async ( ) => await client . SendAsync ( message , CancellationToken . None ) ) ;
36+ }
37+ }
38+ }
Original file line number Diff line number Diff line change 22 <PropertyGroup >
33 <RootNamespace >SocketLabs.Tests</RootNamespace >
44 <AssemblyName >SocketLabs.Tests</AssemblyName >
5- <TargetFramework >net6 .0</TargetFramework >
5+ <TargetFramework >net8 .0</TargetFramework >
66 <AssemblyTitle >SocketLabs.Tests</AssemblyTitle >
77 <IsPackable >false</IsPackable >
88 <Product >SocketLabs.Tests</Product >
2626 <ItemGroup >
2727 <ProjectReference Include =" ..\..\src\SocketLabs\SocketLabs.csproj" />
2828 </ItemGroup >
29+ <ItemGroup >
30+ <Folder Include =" ClientTests\" />
31+ </ItemGroup >
2932</Project >
You can’t perform that action at this time.
0 commit comments