public async Task GetOrCreateDatabase_InvalidCharacters_ThrowsArgumentException() { using var httpTest = new HttpTest(); // Operation result httpTest.RespondWithJson(new { ok = true }); // Logout httpTest.RespondWithJson(new { ok = true }); await using var client = new CouchClient("http://localhost"); Func <Task> action = () => client.GetOrCreateDatabaseAsync <Rebel>("rebel."); var ex = await Assert.ThrowsAsync <ArgumentException>(action); Assert.Contains("invalid characters", ex.Message); }
public async Task GetOrCreateDatabase_CustomName() { using var httpTest = new HttpTest(); // Logout httpTest.RespondWithJson(new { ok = true }); await using var client = new CouchClient("http://localhost"); httpTest.RespondWithJson(new { ok = true }); var rebels = await client.GetOrCreateDatabaseAsync <Rebel>("some_rebels"); httpTest .ShouldHaveCalled("http://localhost/some_rebels") .WithVerb(HttpMethod.Put); Assert.Equal("some_rebels", rebels.Database); }
public async Task GetOrCreateDatabase_CustomCharacterName() { var databaseName = "rebel0_$()+/-"; using var httpTest = new HttpTest(); // Logout httpTest.RespondWithJson(new { ok = true }); await using var client = new CouchClient("http://localhost"); httpTest.RespondWithJson(new { ok = true }); var rebels = await client.GetOrCreateDatabaseAsync <Rebel>(databaseName); httpTest .ShouldHaveCalled("http://localhost/rebel0_%24%28%29%2B%2F-") .WithVerb(HttpMethod.Put); Assert.Equal(databaseName, rebels.Database); }
public async Task GetOrCreateDatabase_402_ReturnDatabase() { using var httpTest = new HttpTest(); // Operation result httpTest.RespondWith(string.Empty, 412); // Logout httpTest.RespondWithJson(new { ok = true }); await using var client = new CouchClient("http://localhost"); var rebels = await client.GetOrCreateDatabaseAsync <Rebel>(); Assert.NotNull(rebels); httpTest .ShouldHaveCalled("http://localhost/rebels") .WithVerb(HttpMethod.Put); Assert.Equal("rebels", rebels.Database); }