1414using System . Threading . Tasks ;
1515using Akavache ;
1616using Akavache . SystemTextJson ;
17- using Xunit ;
17+ using NUnit . Framework ; // switched from xunit
1818
1919namespace Fusillade . Tests . Http
2020{
2121 /// <summary>
2222 /// Checks to make sure that the http scheduler caches correctly.
2323 /// </summary>
24+ [ TestFixture ]
2425 public class HttpSchedulerCachingTests
2526 {
2627 /// <summary>
2728 /// Checks to make sure that the caching functiosn are only called with content.
2829 /// </summary>
2930 /// <returns>A task to monitor the progress.</returns>
30- [ Fact ]
31+ [ Test ]
3132 public async Task CachingFunctionShouldBeCalledWithContent ( )
3233 {
3334 var innerHandler = new TestHttpMessageHandler ( _ =>
@@ -53,16 +54,16 @@ public async Task CachingFunctionShouldBeCalledWithContent()
5354 var client = new HttpClient ( fixture ) ;
5455 var str = await client . GetStringAsync ( new Uri ( "http://lol/bar" ) ) ;
5556
56- Assert . Equal ( "foo" , str ) ;
57- Assert . Equal ( 1 , contentResponses . Count ) ;
58- Assert . Equal ( 3 , contentResponses [ 0 ] . Length ) ;
57+ Assert . That ( str , Is . EqualTo ( "foo" ) ) ;
58+ Assert . That ( contentResponses . Count , Is . EqualTo ( 1 ) ) ;
59+ Assert . That ( contentResponses [ 0 ] . Length , Is . EqualTo ( 3 ) ) ;
5960 }
6061
6162 /// <summary>
6263 /// Checks to make sure that the cache preserves the http headers.
6364 /// </summary>
6465 /// <returns>A task to monitor the progress.</returns>
65- [ Fact ]
66+ [ Test ]
6667 public async Task CachingFunctionShouldPreserveHeaders ( )
6768 {
6869 var innerHandler = new TestHttpMessageHandler ( _ =>
@@ -86,14 +87,14 @@ public async Task CachingFunctionShouldPreserveHeaders()
8687
8788 var client = new HttpClient ( fixture ) ;
8889 var resp = await client . GetAsync ( new Uri ( "http://lol/bar" ) ) ;
89- Assert . Equal ( "\" worifjw\" " , etagResponses [ 0 ] ) ;
90+ Assert . That ( etagResponses [ 0 ] , Is . EqualTo ( "\" worifjw\" " ) ) ;
9091 }
9192
9293 /// <summary>
9394 /// Does a round trip integration test.
9495 /// </summary>
9596 /// <returns>A task to monitor the progress.</returns>
96- [ Fact ]
97+ [ Test ]
9798 public async Task RoundTripIntegrationTest ( )
9899 {
99100 var aka = CacheDatabase . CreateBuilder ( ) . WithSerializerSystemTextJson ( ) . Build ( ) ;
@@ -112,19 +113,18 @@ public async Task RoundTripIntegrationTest()
112113 var client = new HttpClient ( cachingHandler ) ;
113114 var origData = await client . GetStringAsync ( new Uri ( "http://httpbin.org/get" ) ) ;
114115
115- Assert . True ( origData . Contains ( "origin" ) ) ;
116+ Assert . That ( origData . Contains ( "origin" ) , Is . True ) ;
116117
117- // Some Akavache cache implementations expose a single key, not a collection.
118118 var singleKey = await cache . GetAllKeys ( ) ;
119- Assert . False ( string . IsNullOrEmpty ( singleKey ) ) ;
120- Assert . StartsWith ( "HttpSchedulerCache_" , singleKey , StringComparison . Ordinal ) ;
119+ Assert . That ( string . IsNullOrEmpty ( singleKey ) , Is . False ) ;
120+ Assert . That ( singleKey . StartsWith ( "HttpSchedulerCache_" , StringComparison . Ordinal ) , Is . True ) ;
121121
122122 var offlineHandler = new OfflineHttpMessageHandler ( async ( rq , key , ct ) => await cache . Get ( key ) ) ;
123123
124124 client = new HttpClient ( offlineHandler ) ;
125125 var newData = await client . GetStringAsync ( new Uri ( "http://httpbin.org/get" ) ) ;
126126
127- Assert . Equal ( origData , newData ) ;
127+ Assert . That ( origData , Is . EqualTo ( newData ) ) ;
128128
129129 bool shouldDie = true ;
130130 try
@@ -137,7 +137,7 @@ public async Task RoundTripIntegrationTest()
137137 Console . WriteLine ( ex ) ;
138138 }
139139
140- Assert . False ( shouldDie ) ;
140+ Assert . That ( shouldDie , Is . False ) ;
141141 }
142142
143143 /// <summary>
@@ -146,14 +146,13 @@ public async Task RoundTripIntegrationTest()
146146 /// <param name="method">The name of the method.</param>
147147 /// <param name="shouldCache">If it should be cached or not.</param>
148148 /// <returns>A task to monitor the progress.</returns>
149- [ Theory ]
150- [ InlineData ( "GET" , true ) ]
151- [ InlineData ( "HEAD" , true ) ]
152- [ InlineData ( "OPTIONS" , true ) ]
153- [ InlineData ( "POST" , false ) ]
154- [ InlineData ( "DELETE" , false ) ]
155- [ InlineData ( "PUT" , false ) ]
156- [ InlineData ( "WHATEVER" , false ) ]
149+ [ TestCase ( "GET" , true ) ]
150+ [ TestCase ( "HEAD" , true ) ]
151+ [ TestCase ( "OPTIONS" , true ) ]
152+ [ TestCase ( "POST" , false ) ]
153+ [ TestCase ( "DELETE" , false ) ]
154+ [ TestCase ( "PUT" , false ) ]
155+ [ TestCase ( "WHATEVER" , false ) ]
157156 public async Task OnlyCacheRelevantMethods ( string method , bool shouldCache )
158157 {
159158 var innerHandler = new TestHttpMessageHandler ( _ =>
@@ -178,7 +177,7 @@ public async Task OnlyCacheRelevantMethods(string method, bool shouldCache)
178177 var request = new HttpRequestMessage ( new ( method ) , "http://lol/bar" ) ;
179178 await client . SendAsync ( request ) ;
180179
181- Assert . Equal ( shouldCache , cached ) ;
180+ Assert . That ( cached , Is . EqualTo ( shouldCache ) ) ;
182181 }
183182 }
184183}
0 commit comments