|
3 | 3 | using Flurl.Http.Testing;
|
4 | 4 | using System;
|
5 | 5 | using System.Collections.Generic;
|
| 6 | +using System.Linq; |
6 | 7 | using System.Net.Http;
|
7 | 8 | using System.Threading.Tasks;
|
8 | 9 | using CouchDB.Driver.Extensions;
|
@@ -357,6 +358,50 @@ public async Task AddOrUpdateRange()
|
357 | 358 | .ShouldHaveCalled("http://localhost/rebels/_bulk_docs")
|
358 | 359 | .WithVerb(HttpMethod.Post);
|
359 | 360 | }
|
| 361 | + |
| 362 | + [Fact] |
| 363 | + public async Task DeleteRange() |
| 364 | + { |
| 365 | + using var httpTest = new HttpTest(); |
| 366 | + // Response |
| 367 | + httpTest.RespondWithJson(new[] { |
| 368 | + new { Id = "111", Ok = true, Rev = "111" }, |
| 369 | + new { Id = "222", Ok = true, Rev = "222" }, |
| 370 | + }); |
| 371 | + // Logout |
| 372 | + httpTest.RespondWithJson(new { ok = true }); |
| 373 | + |
| 374 | + var moreRebels = new[] { |
| 375 | + new Rebel { Name = "Luke", Id = "1" }, |
| 376 | + new Rebel { Name = "Leia", Id = "2" } |
| 377 | + }.Cast<DocumentId>().ToArray(); |
| 378 | + await _rebels.DeleteRangeAsync(moreRebels); |
| 379 | + httpTest |
| 380 | + .ShouldHaveCalled("http://localhost/rebels/_bulk_docs") |
| 381 | + .WithVerb(HttpMethod.Post); |
| 382 | + } |
| 383 | + |
| 384 | + [Fact] |
| 385 | + public async Task DeleteRange_Docs() |
| 386 | + { |
| 387 | + using var httpTest = new HttpTest(); |
| 388 | + // Response |
| 389 | + httpTest.RespondWithJson(new[] { |
| 390 | + new { Id = "111", Ok = true, Rev = "111" }, |
| 391 | + new { Id = "222", Ok = true, Rev = "222" }, |
| 392 | + }); |
| 393 | + // Logout |
| 394 | + httpTest.RespondWithJson(new { ok = true }); |
| 395 | + |
| 396 | + var moreRebels = new[] { |
| 397 | + new Rebel { Name = "Luke", Id = "1" }, |
| 398 | + new Rebel { Name = "Leia", Id = "2" } |
| 399 | + }; |
| 400 | + await _rebels.DeleteRangeAsync(moreRebels); |
| 401 | + httpTest |
| 402 | + .ShouldHaveCalled("http://localhost/rebels/_bulk_docs") |
| 403 | + .WithVerb(HttpMethod.Post); |
| 404 | + } |
360 | 405 |
|
361 | 406 | #endregion
|
362 | 407 |
|
|
0 commit comments