예제 #1
0
 public void XmlAccept()
 {
     client.PreferredFormat = ContentType.ResourceFormat.Xml;
     client.UseFormatParam  = false;
     client.Read <Patient>("1");
     HttpTests.AssertResourceResponseConformsTo(client, client.PreferredFormat);
 }
예제 #2
0
 public void JsonFormat()
 {
     client.PreferredFormat = ContentType.ResourceFormat.Json;
     client.UseFormatParam  = true;
     client.Read <Patient>("1");
     HttpTests.AssertResourceResponseConformsTo(client, client.PreferredFormat);
 }
예제 #3
0
        public void UpdateTagsUsingPost()
        {
            var rl = new ResourceLocation(latest.SelfLink);

            var update   = new Tag(NUTAG, Tag.FHIRTAGNS, "newVersion");
            var existing = new Tag(OTHERTAG, Tag.FHIRTAGNS);

            HttpTests.AssertSuccess(client, () => client.AffixTags(
                                        new List <Tag> {
                update
            }, ResourceType.Patient, rl.Id));

            var result = client.Fetch <Patient>(latest.Id);

            if (result.Tags.Count() != 2)
            {
                TestResult.Fail("update modified the number of tags");
            }

            if (!result.Tags.Any(t => t.Equals(existing)))
            {
                TestResult.Fail("update removed an existing but unchanged tag");
            }

            if (!result.Tags.Any(t => t.Equals(update) && t.Label == update.Label))
            {
                TestResult.Fail("update did not change the tag");
            }

            if (result.SelfLink != latest.SelfLink)
            {
                TestResult.Fail("updating the tags created a new version");
            }
        }
예제 #4
0
        public void TryReadUnknownResourceType()
        {
            ResourceLocation rl = new ResourceLocation(client.Endpoint);

            rl.Collection = "thisreallywondexist";
            rl.Id         = "1";

            HttpTests.AssertFail(client, () => client.Fetch <Patient>(rl.ToUri()), HttpStatusCode.NotFound);
        }
예제 #5
0
        public void GetTestDataPerson()
        {
            var pat = client.Read <Patient>("1");

            HttpTests.AssertHttpOk(client);

            HttpTests.AssertValidResourceContentTypePresent(client);
            HttpTests.AssertLastModifiedPresent(client);
            HttpTests.AssertContentLocationPresentAndValid(client);
        }
예제 #6
0
        public void SearchUsingTag()
        {
            var tag = new Tag(OTHERTAG, Tag.FHIRTAGNS, "dummy");

            Bundle result = null;

            HttpTests.AssertSuccess(client, () => result = client.Search(ResourceType.Patient, "_tag", OTHERTAG));

            if (result.Entries.ByTag(OTHERTAG).Count() != 1)
            {
                TestResult.Fail("could not retrieve patient by its tag");
            }
        }
예제 #7
0
        public void GetServerWideTags()
        {
            IEnumerable <Tag> tags = null;

            HttpTests.AssertSuccess(client, () => tags = client.GetTags());

            var tagStrings = tags.FilterFhirTags().Where(t => t.Term != null).Select(t => t.Term);

            if (!tagStrings.Contains(NUTAG) || !tagStrings.Contains(OTHERTAG))
            {
                TestResult.Fail("expected tags not found in server-wide tag list");
            }
        }
예제 #8
0
        public void GetInstanceHistoryTags()
        {
            IEnumerable <Tag> tags = null;

            var rl = new ResourceLocation(latest.SelfLink);

            HttpTests.AssertSuccess(client, () => tags = client.GetTags(ResourceType.Patient, rl.Id, rl.VersionId));

            var tagStrings = tags.FilterFhirTags().Where(t => t.Term != null).Select(t => t.Term);

            if (!tagStrings.Contains(NUTAG) || !tagStrings.Contains(OTHERTAG))
            {
                TestResult.Fail("expected tags not found in resource instance tag list");
            }
        }
예제 #9
0
        public void TestTagsOnCreateAndRead()
        {
            var tags = new List <Tag>()
            {
                new Tag(NUTAG, Tag.FHIRTAGNS, "readTagTest")
            };

            HttpTests.AssertSuccess(client, () => latest = client.Create <Patient>(DemoData.GetDemoPatient(), tags));

            if (latest.Tags == null)
            {
                TestResult.Fail("create did not return any tags");
            }

            var nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);

            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("create did not return specified tag");
            }

            var read = client.Fetch <Patient>(latest.Id);

            if (read.Tags == null)
            {
                TestResult.Fail("read did not return any tags");
            }
            nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);
            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("read did not return specified tag");
            }

            var vread = client.Fetch <Patient>(latest.SelfLink);

            if (vread.Tags == null)
            {
                TestResult.Fail("vread did not return any tags");
            }
            nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);
            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("vread did not return specified tag");
            }

            original = latest;
        }
예제 #10
0
        public void UpdateTagsOnUpdate()
        {
            if (original == null)
            {
                TestResult.Skipped();
            }

            // Update one tag, add another
            var tags = new List <Tag>()
            {
                new Tag(NUTAG, Tag.FHIRTAGNS, "readTagTest2"),
                new Tag(OTHERTAG, Tag.FHIRTAGNS, "dummy")
            };

            HttpTests.AssertSuccess(client, () => latest = client.Fetch <Patient>(original.Id));

            latest.Tags = tags;

            HttpTests.AssertSuccess(client, () => client.Update <Patient>(latest));

            var read = client.Fetch <Patient>(latest.Id);

            if (read.Tags == null)
            {
                TestResult.Fail("fetch after update did not return any tags");
            }

            if (read.Tags.Count() != 2)
            {
                TestResult.Fail(String.Format("Wrong number of tags after update: {0}, expected 2", read.Tags.Count()));
            }
            var nutags = read.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);

            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest2")
            {
                TestResult.Fail("update did not replace value in tag");
            }
            var othertags = read.Tags.FindByTerm(OTHERTAG, Tag.FHIRTAGNS);

            if (othertags.Count() != 1 || othertags.First().Label != "dummy")
            {
                TestResult.Fail("update failed to add new tag");
            }

            latest = read;
        }
예제 #11
0
        public void GetResourceWideTags()
        {
            IEnumerable <Tag> tags = null;

            HttpTests.AssertSuccess(client, () => tags = client.GetTags(ResourceType.Patient));

            var tagStrings = tags.FilterFhirTags().Where(t => t.Term != null).Select(t => t.Term);

            if (!tagStrings.Contains(NUTAG) || !tagStrings.Contains(OTHERTAG))
            {
                TestResult.Fail("expected tags not found in resource-wide tag list");
            }

            HttpTests.AssertSuccess(client, () => tags = client.GetTags(ResourceType.Conformance));
            tagStrings = tags.FilterFhirTags().Where(t => t.Term != null).Select(t => t.Term);
            if (tagStrings.Contains(NUTAG) || tagStrings.Contains(OTHERTAG))
            {
                TestResult.Fail("tags showed up while listing tags for another resource type");
            }
        }
예제 #12
0
        public void DeleteTagsOnVersionUsingDelete()
        {
            var rl = new ResourceLocation(latest.SelfLink);

            var delete   = new Tag(NUTAG, Tag.FHIRTAGNS);
            var existing = new Tag(OTHERTAG, Tag.FHIRTAGNS);

            HttpTests.AssertSuccess(client, () => client.DeleteTags(
                                        new List <Tag> {
                delete
            }, ResourceType.Patient, rl.Id, rl.VersionId));

            var result = client.Fetch <Patient>(latest.Id);

            if (result.Tags.Count() != 1)
            {
                TestResult.Fail("delete resulted in an unexpected number of remaining tags");
            }

            if (!result.Tags.Any(t => t.Equals(existing)))
            {
                TestResult.Fail("delete removed an existing tag the should be untouched");
            }

            if (result.Tags.Any(t => t.Equals(delete)))
            {
                TestResult.Fail("delete did not remove the tag");
            }

            if (result.SelfLink != latest.SelfLink)
            {
                TestResult.Fail("deleting the tags created a new version");
            }

            //TODO: Check whether taglists on older versions remain unchanged
        }
예제 #13
0
 public void TryReadNonExistingResource()
 {
     HttpTests.AssertFail(client, () => client.Read <Patient>("3141592unlikely"), HttpStatusCode.NotFound);
 }