public void WithVersion() { var identity = new ResourceIdentity("http://localhost/some/sub/path/fhir/Patient/B256/"); var newIdentity = identity.WithVersion("3141"); Assert.AreEqual("B256", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); identity = new ResourceIdentity("http://localhost/some/sub/path/fhir/Organization/3/_history/X98"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); identity = new ResourceIdentity("Organization/3"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); identity = new ResourceIdentity("Organization/3/_history/X98"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); var identity2 = identity.WithoutVersion(); Assert.AreEqual("Organization/3", identity2.ToString()); }
public void AddVersionNumberToExistingIdentifier() { var identity = new ResourceIdentity("http://localhost/some/sub/path/fhir/patient/B256/"); var newIdentity = identity.WithVersion("3141"); Assert.AreEqual("B256", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); identity = new ResourceIdentity("http://localhost/some/sub/path/fhir/organization/3/_history/X98"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); // mh: relativ uri's: identity = new ResourceIdentity("organization/3"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); identity = new ResourceIdentity("organization/3/_history/X98"); newIdentity = identity.WithVersion("3141"); Assert.AreEqual("3", newIdentity.Id); Assert.AreEqual("3141", newIdentity.VersionId); }
public static Uri HistoryKeyFor(this IGenerator generator, Uri key) { var identity = new ResourceIdentity(key); string vid = generator.NextVersionId(identity.ResourceType); Uri result = identity.WithVersion(vid); return(result); }