1+ using System ;
2+ using System . Net . Http ;
3+ using System . Net . Http . Headers ;
4+ using System . Threading . Tasks ;
5+ using Microsoft . AspNetCore . Hosting ;
6+ using Microsoft . AspNetCore . TestHost ;
7+ using Microsoft . Extensions . DependencyInjection ;
8+ using SqlStreamStore ;
9+ using SqlStreamStore . HAL ;
10+ using SqlStreamStore . Server ;
11+ using Xunit ;
12+
13+ namespace SQLStreamStore . Server . Tests
14+ {
15+ public class SqlStreamStoreServerStartupTests : IDisposable
16+ {
17+ private readonly InMemoryStreamStore _streamStore ;
18+ private readonly IWebHost _host ;
19+ private TestServer _server ;
20+ private readonly HttpClient _httpClient ;
21+
22+ public SqlStreamStoreServerStartupTests ( )
23+ {
24+ _streamStore = new InMemoryStreamStore ( ) ;
25+
26+ _server = new TestServer (
27+ new WebHostBuilder ( )
28+ . UseStartup ( new SqlStreamStoreServerStartup (
29+ _streamStore ,
30+ new SqlStreamStoreMiddlewareOptions
31+ {
32+ UseCanonicalUrls = false
33+ } ) ) ) ;
34+
35+ _httpClient = new HttpClient ( _server . CreateHandler ( ) )
36+ {
37+ BaseAddress = new UriBuilder ( ) . Uri
38+ } ;
39+ }
40+
41+ [ Fact ]
42+ public async Task StartsUp ( )
43+ {
44+ using ( await _httpClient . SendAsync ( new HttpRequestMessage ( HttpMethod . Get , "/" )
45+ {
46+ Headers = { Accept = { new MediaTypeWithQualityHeaderValue ( "application/hal+json" ) } }
47+ } ) )
48+ {
49+ }
50+ }
51+
52+ public void Dispose ( )
53+ {
54+ _streamStore ? . Dispose ( ) ;
55+ _host ? . Dispose ( ) ;
56+ _httpClient ? . Dispose ( ) ;
57+ }
58+ }
59+ }
0 commit comments