public void TestEscaping() { var url = new RestUrl("http://www.server.org/fhir"); url.AddParam("_since", FhirDateTime.Now().Value); var output = url.Uri; Assert.IsFalse(output.ToString().Contains("+")); // don't use un-escaped + }
public void Query() { RestUrl endpoint = new RestUrl("http://localhost/fhir"); RestUrl resturi; resturi = endpoint.Search("organization").AddParam("family", "Johnson").AddParam("given", "William"); Assert.AreEqual("http://localhost/fhir/organization/_search?family=Johnson&given=William", resturi.AsString); var rl2 = new RestUrl(resturi.Uri); rl2.AddParam("given", "Piet"); Assert.AreEqual("http://localhost/fhir/organization/_search?family=Johnson&given=William&given=Piet", rl2.AsString); }
public void ParamManipulation() { var rl = new RestUrl("http://someserver.org/fhir/Patient/search?name=Kramer&name=Moreau&oauth=XXX"); rl.AddParam("newParamA", "1"); rl.SetParam("newParamB", "2"); Assert.IsTrue(rl.ToString().EndsWith("oauth=XXX&newParamA=1&newParamB=2")); rl.SetParam("newParamA", "3"); rl.ClearParam("newParamB"); Assert.IsTrue(rl.ToString().EndsWith("oauth=XXX&newParamA=3")); rl.AddParam("newParamA", "4"); Assert.IsTrue(rl.ToString().EndsWith("oauth=XXX&newParamA=3&newParamA=4")); rl.AddParam("newParamB", "5"); Assert.IsTrue(rl.ToString().EndsWith("oauth=XXX&newParamA=3&newParamA=4&newParamB=5")); rl.SetParam("newParamA", "6"); Assert.IsTrue(rl.ToString().EndsWith("oauth=XXX&newParamA=6&newParamB=5")); rl.ClearParams(); Assert.IsTrue(rl.ToString().EndsWith("search")); }