public void TestStoreBinaryEntry() { byte[] data = UTF8Encoding.UTF8.GetBytes("Hello world!"); var e = new ResourceEntry <Binary>(); e.AuthorName = "Ewout"; e.Id = new Uri("binary/@3141", UriKind.Relative); e.Links.SelfLink = new Uri("binary/@3141/history/@1", UriKind.Relative); e.Resource = new Binary() { Content = data, ContentType = "text/plain" }; // Test store var result = (ResourceEntry <Binary>)_store.AddEntry(e); Assert.IsNotNull(result.Resource); CollectionAssert.AreEqual(data, result.Resource.Content); Assert.AreEqual("text/plain", result.Resource.ContentType); // Test retrieve ResourceEntry <Binary> result2 = (ResourceEntry <Binary>)_store.FindEntryById(e.Id); Assert.IsNotNull(result2); CollectionAssert.AreEqual(e.Resource.Content, result2.Resource.Content); Assert.AreEqual(e.Resource.ContentType, result2.Resource.ContentType); // Test update byte[] data2 = UTF8Encoding.UTF8.GetBytes("Hello world!?"); e.Resource = new Binary() { Content = data2, ContentType = "text/plain" }; e.SelfLink = new Uri("binary/@3141/history/@2", UriKind.Relative); ResourceEntry <Binary> result3 = (ResourceEntry <Binary>)_store.AddEntry(e); Assert.IsNotNull(result3); Assert.AreEqual(e.Resource.ContentType, result3.Resource.ContentType); CollectionAssert.AreEqual(e.Resource.Content, result3.Resource.Content); // Test fetch latest ResourceEntry <Binary> result4 = (ResourceEntry <Binary>)_store.FindEntryById(e.Id); Assert.AreEqual(result4.Id, result3.Id); var allVersions = _store.ListVersionsById(e.Id); Assert.AreEqual(2, allVersions.Count()); Assert.AreEqual(allVersions.First().Id, e.Id); Assert.AreEqual(allVersions.Skip(1).First().Id, result.Id); }
public void SimpleStoreAndRetrieve() { _store.EraseData(); _store.AddEntry(_stockPatient); ResourceEntry readBack = (ResourceEntry)_store.FindEntryById(_stockPatient.Id); Assert.IsNotNull(readBack); Assert.IsNotNull(readBack.Id); Assert.AreEqual(_stockPatient.Id, readBack.Id); Assert.IsNotNull(readBack.Links.SelfLink); Assert.IsNotNull(readBack.LastUpdated); Assert.AreEqual(FhirSerializer.SerializeResourceToJson(_stockPatient.Resource), FhirSerializer.SerializeResourceToJson(readBack.Resource)); }