public CouchDbTests() { _dbRequester = new HttpRequester(DbUrl); var head = _dbRequester.HeadAsync().Result; if(head.IsSuccess) _dbRequester.DeleteAsync().Wait(); }
public CouchDbTests() { _dbRequester = HttpRequester.Create(DbUrlWithCredentials); var head = _dbRequester.HeadAsync().Result; if (head.IsSuccess) { _dbRequester.DeleteAsync().Wait(); } }
public async void Flow_tests() { var person = new Person { Id = Guid.NewGuid(), FirstName = "Daniel", LastName = "Wertheim", Age = 35 }; using (var requester = new HttpRequester($"{_server.BaseAddress}/api/persons/", _server.Handler)) { var forTheCreatingPut = await requester.PutEntityAsJsonAsync(person); forTheCreatingPut.TheResponse(should => should .BeSuccessful() .HaveStatus(HttpStatusCode.Created)); var forTheGet = await requester.GetAsync(person.Id.ToString()); forTheGet.TheResponse(should => should .BeSuccessful() .BeJsonResponse() .HaveSpecificValueFor("firstName", "Daniel")); person.Age = 42; var forTheUpdatingPut = await requester.PutEntityAsJsonAsync(person); forTheUpdatingPut.TheResponse(should => should .BeSuccessful() .HaveStatus(HttpStatusCode.OK)); var forTheDelete = await requester.DeleteAsync(person.Id.ToString()); forTheDelete.TheResponse(should => should .BeSuccessful() .HaveStatus(HttpStatusCode.OK)); var forTheCreatingPost = await requester.PostEntityAsJsonAsync(person); forTheCreatingPost.TheResponse(should => should .BeSuccessful() .HaveStatus(HttpStatusCode.Created) .BeJsonResponse() .NotHavingSpecificValueFor("id", person.Id)); } }
public async void Can_use_basic_auth_on_HttpRequester() { using (var requester = new HttpRequester(DbUrl).Configure(cfg => cfg.WithBasicAuthorization(U, P))) { var db = await requester.PutAsync(); db.TheResponse(should => should.BeSuccessful()); var newDoc = await requester.PostJsonAsync("{\"value\":\"can_use_basic_auth_on_HttpRequester\"}"); newDoc.TheResponse(should => should.BeSuccessful()); var deleteDoc = await requester.DeleteAsync(newDoc.Location.Replace(requester.Config.BaseAddress.ToString(), string.Empty) + "?rev=" + newDoc.ETag); deleteDoc.TheResponse(should => should.BeSuccessful()); } }