Skip to content

Commit 8f7a062

Browse files
committed
Add tests that inner exception is the original exception so the underlying cause can be diagnosed
1 parent 1df49c0 commit 8f7a062

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/CouchDB.Driver.UnitTests/Client_Tests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public async Task ConflictException()
189189

190190
using (var client = new CouchClient("http://localhost"))
191191
{
192-
await Assert.ThrowsAsync<CouchConflictException>(() => client.CreateDatabaseAsync<Rebel>());
192+
var couchException = await Assert.ThrowsAsync<CouchConflictException>(() => client.CreateDatabaseAsync<Rebel>());
193+
Assert.IsType<Flurl.Http.FlurlHttpException>(couchException.InnerException);
193194
}
194195
}
195196
}
@@ -203,7 +204,8 @@ public async Task NotFoundException()
203204

204205
using (var client = new CouchClient("http://localhost"))
205206
{
206-
await Assert.ThrowsAsync<CouchNotFoundException>(() => client.DeleteDatabaseAsync<Rebel>());
207+
var couchException = await Assert.ThrowsAsync<CouchNotFoundException>(() => client.DeleteDatabaseAsync<Rebel>());
208+
Assert.IsType<Flurl.Http.FlurlHttpException>(couchException.InnerException);
207209
}
208210
}
209211
}
@@ -218,7 +220,8 @@ public void BadRequestException()
218220
using (var client = new CouchClient("http://localhost"))
219221
{
220222
var db = client.GetDatabase<Rebel>();
221-
Assert.Throws<CouchNoIndexException>(() => db.UseIndex("aoeu").ToList());
223+
var couchException = Assert.Throws<CouchNoIndexException>(() => db.UseIndex("aoeu").ToList());
224+
Assert.IsType<Flurl.Http.FlurlHttpException>(couchException.InnerException);
222225
}
223226
}
224227
}
@@ -237,6 +240,8 @@ public async Task GenericExceptionWithMessage()
237240
var db = client.GetDatabase<Rebel>();
238241
var couchException = await Assert.ThrowsAsync<CouchException>(() => db.FindAsync("aoeu"));
239242
Assert.Equal(message, couchException.Message);
243+
Assert.Equal(reason, couchException.Reason);
244+
Assert.IsType<Flurl.Http.FlurlHttpException>(couchException.InnerException);
240245
}
241246
}
242247
}
@@ -252,6 +257,7 @@ public async Task GenericExceptionNoMessage()
252257
{
253258
var db = client.GetDatabase<Rebel>();
254259
var couchException = await Assert.ThrowsAsync<CouchException>(() => db.FindAsync("aoeu"));
260+
Assert.IsType<Flurl.Http.FlurlHttpException>(couchException.InnerException);
255261
}
256262
}
257263
}

0 commit comments

Comments
 (0)