예제 #1
0
        public async Task UpdateDelete_UsingResourceIdentity_ResultReturned()
        {
            var client = new FhirClient(_endpoint)
            {
                PreferredFormat    = ResourceFormat.Json,
                ReturnFullResource = true
            };

            var pat = new Patient()
            {
                Name = new List <HumanName>()
                {
                    new HumanName()
                    {
                        Given = new List <string>()
                        {
                            "test_given"
                        },
                        Family = new List <string>()
                        {
                            "test_family"
                        },
                    }
                },
                Id = "async-test-patient"
            };

            // Create the patient
            Console.WriteLine("Creating patient...");
            Patient p = await client.UpdateAsync <Patient>(pat);

            Assert.IsNotNull(p);

            // Refresh the patient
            Console.WriteLine("Refreshing patient...");
            await client.RefreshAsync(p);

            // Delete the patient
            Console.WriteLine("Deleting patient...");
            await client.DeleteAsync(p);

            Console.WriteLine("Reading patient...");
            Func <Task> act = async() =>
            {
                await client.ReadAsync <Patient>(new ResourceIdentity("/Patient/async-test-patient"));
            };

            // VERIFY //
            Assert.ThrowsException <FhirOperationException>(act, "the patient is no longer on the server");


            Console.WriteLine("Test Completed");
        }