public void DeleteTagsOnVersionUsingDelete() { var identity = new ResourceIdentity(latest.SelfLink); var delete = new Tag(NUTAG, Tag.FHIRTAGSCHEME_GENERAL); var existing = new Tag(_otherTag, Tag.FHIRTAGSCHEME_GENERAL); HttpTests.AssertSuccess(client, () => client.DeleteTags(identity, new List<Tag> { delete })); var result = client.Read<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 }
public void TagToString() { var tag = new Tag("dog", "http://test.nl/tags", "Een hond"); Assert.AreEqual("dog@http://test.nl/tags (Een hond)", tag.ToString()); tag = new Tag("dog", "http://test.nl/tags"); Assert.AreEqual("dog@http://test.nl/tags", tag.ToString()); }
public void TagEquality() { var t1 = new Tag("dog", new Uri("http://nu.nl")); var t2 = new Tag("dog", new Uri("http://knmi.nl") ); var t3 = new Tag("dog", "http://knmi.nl"); Assert.AreNotEqual(t1, t2); Assert.AreNotEqual(t1, t3); Assert.AreEqual(t2, t3); }
//internal static void SerializeTagList(IEnumerable<Tag> list, XmlWriter writer) //{ // XElement xTagList = new XElement(BundleXmlParser.XFHIRNS + TAGLIST_TYPE); // foreach (var tag in list) // xTagList.Add(CreateTagCategoryPropertyXml(tag, useAtomNs: false)); // xTagList.WriteTo(writer); //} internal static XElement CreateTagCategoryPropertyXml(Tag tag, bool useAtomNs = true) { XElement result = useAtomNs ? new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_CATEGORY) : new XElement(BundleXmlParser.XFHIRNS + BundleXmlParser.XATOM_CATEGORY); if (!String.IsNullOrEmpty(tag.Term)) result.Add(new XAttribute(BundleXmlParser.XATOM_CAT_TERM, tag.Term)); if (!String.IsNullOrEmpty(tag.Label)) result.Add(new XAttribute(BundleXmlParser.XATOM_CAT_LABEL, tag.Label)); result.Add(new XAttribute(BundleXmlParser.XATOM_CAT_SCHEME, tag.Scheme.ToString())); return result; }
public void TagListExclusion() { IList<Tag> tl = new List<Tag>(); var n1 = new Tag("http://nu.nl", Tag.FHIRTAGSCHEME_GENERAL, "v1"); tl.Add(n1); tl.Add(new Tag("http://dan.nl", Tag.FHIRTAGSCHEME_GENERAL, "v2")); IList<Tag> tl2 = new List<Tag>(); tl2.Add(new Tag("http://nu.nl", Tag.FHIRTAGSCHEME_GENERAL)); tl2.Add(new Tag("http://nooit.nl", Tag.FHIRTAGSCHEME_GENERAL)); var result = tl.Exclude(tl2); Assert.AreEqual(new Tag("http://dan.nl", Tag.FHIRTAGSCHEME_GENERAL), result.Single()); result = tl.Exclude(n1); Assert.AreEqual(1, result.Count()); }
public Tag BsonValueToTag(BsonValue item) { Tag tag = new Tag( item["term"].AsString, new Uri(item["scheme"].AsString), item["label"].AsString); return tag; }
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 }
public void UpdateTagsOnVersionUsingPost() { var rl = new ResourceLocation(latest.SelfLink); var update = new Tag(NUTAG, Tag.FHIRTAGNS, "newVersionForVersion"); var existing = new Tag(OTHERTAG, Tag.FHIRTAGNS); HttpTests.AssertSuccess(client, () => client.AffixTags( new List<Tag> { update }, ResourceType.Patient, rl.Id, rl.VersionId)); 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"); //TODO: Check whether taglists on older versions remain unchanged }
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"); }
public static IEnumerable<Tag> Exclude(this IEnumerable<Tag> tags, Tag tag) { if (tag == null) Error.ArgumentNull("tag"); return tags.Where(t => !Equals(t,tag)); }
public void Collect(Tag tag) { string scheme = Assigned(tag.Scheme) ? tag.Scheme.ToString() : null; string term = tag.Term; string label = tag.Label; //string tagstring = glue("/", scheme, term); BsonDocument value = new BsonDocument() { { "scheme", scheme }, { "term", term }, { "label", label } }; Write(InternalField.TAG, value); }
public void UpdateTagsUsingPost() { var identity = new ResourceIdentity(latest.SelfLink); var update = new Tag(NUTAG, Tag.FHIRTAGSCHEME_GENERAL, "newVersion"); var existing = new Tag(_otherTag, Tag.FHIRTAGSCHEME_GENERAL); client.AffixTags(identity, new List<Tag> { update }); HttpTests.AssertNoContent(client); var result = client.Read<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"); }
public void SearchUsingTag() { var tag = new Tag(_otherTag, Tag.FHIRTAGSCHEME_GENERAL, "dummy"); Bundle result = null; HttpTests.AssertSuccess(client, () => result = client.Search<Patient>(new string[] { "_tag="+_otherTag } )); if (result.Entries.ByTag(_otherTag).Count() != 1) TestResult.Fail("could not retrieve patient by its tag"); }
public void TagEquality() { var t1 = new Tag("http://www.nu.nl", "labeltje"); var t2 = new Tag("http://www.nu.nl", "labeltje"); var t3 = new Tag("http://www.nu.nl", "labeltjes"); var t4 = new Tag("http://www.nu.nl/x", "labeltje"); Assert.AreEqual(t1, t2); Assert.AreNotEqual(t1, t4); Assert.AreNotEqual(t1, t3); }