Ejemplo n.º 1
0
        public void CreateBinary()
        {
            var bin = DemoData.GetDemoBinary();
            ResourceEntry <Binary> received = null;

            HttpTests.AssertSuccess(client, () => received = client.Create <Binary>(bin));

            HttpTests.AssertLocationPresentAndValid(client);

            var binResult = client.Read <Binary>(received.Id);

            if (binResult.Resource.ContentType != bin.ContentType)
            {
                TestResult.Fail("Created binary of type " + bin.ContentType +
                                "but received " + client.LastResponseDetails.ContentType);
            }

            HttpTests.AssertContentLocationValidIfPresent(client);

            compareData(bin.Content, binResult);

            binaryId = received.Id;
        }
        private Uri tryCreatePatient(FhirClient client, ResourceFormat formatIn, string id = null)
        {
            client.PreferredFormat = formatIn;
            ResourceEntry <Patient> created = null;

            Patient demopat = DemoData.GetDemoPatient();

            if (id == null)
            {
                HttpTests.AssertSuccess(client, () => created = client.Create <Patient>(demopat));
            }
            else
            {
                HttpTests.AssertSuccess(client, () => created = client.Create <Patient>(demopat, id));

                var ep = new RestUrl(client.Endpoint);
                if (!ep.IsEndpointFor(created.Id))
                {
                    TestResult.Fail("Location of created resource is not located within server endpoint");
                }

                var rl = new ResourceIdentity(created.Id);
                if (rl.Id != id)
                {
                    TestResult.Fail("Server refused to honor client-assigned id");
                }
            }

            HttpTests.AssertLocationPresentAndValid(client);

            // Create bevat geen response content meer. Terecht verwijderd?:
            // EK: Niet helemaal, er is weliswaar geen data meer gereturned, maar de headers (id, versie, modified) worden
            // nog wel geupdate
            HttpTests.AssertContentLocationValidIfPresent(client);

            return(created.SelfLink);
        }