public void TestBatchRemoval() { _store.EraseData(); byte[] data = UTF8Encoding.UTF8.GetBytes("Hello world!"); ResourceEntry <Binary> e = new ResourceEntry <Binary>(); e.AuthorName = "Ewout"; e.Resource = new Binary { Content = data, ContentType = "text/plain" }; var rl = ResourceLocation.Build("binary", "3141"); e.Id = rl.ToUri(); rl.VersionId = "1"; e.SelfLink = rl.ToUri(); var batchGuid = Guid.NewGuid(); ResourceEntry <Binary> result = (ResourceEntry <Binary>)_store.AddEntry(e, batchGuid); // Store 5 others with another batchguid batchGuid = Guid.NewGuid(); for (int i = 0; i < 5; i++) { rl = ResourceLocation.Build("binary", (10 + i).ToString()); e.Id = rl.ToUri(); rl.VersionId = "1"; e.SelfLink = rl.ToUri(); result = (ResourceEntry <Binary>)_store.AddEntry(e, batchGuid); } _store.PurgeBatch(batchGuid); var result2 = _store.ListCollection("binary"); Assert.AreEqual(1, result2.Count()); Assert.AreEqual("3141", ResourceLocation.GetIdFromResourceId(result2.First().Id)); using (var s3 = new AmazonS3Storage()) { s3.Open(); var names = s3.ListNames(); Assert.AreEqual(1, names.Length); Assert.IsTrue(names.First().Contains("3141")); } }
public void ListRecordsByResourceType() { _store.EraseData(); DateTimeOffset now = DateTimeOffset.UtcNow; DateTime stampi = new DateTime(now.Ticks, DateTimeKind.Unspecified); stampi = stampi.AddHours(5); DateTimeOffset stamp = new DateTimeOffset(stampi, new TimeSpan(5, 0, 0)); var importer = new ResourceImporter(new Uri("http://localhost")); for (int i = 0; i < 5; i++) { var tst = _stockPatients[i]; importer.QueueNewEntry(tst); } for (int i = 0; i < 5; i++) { var tst = _stockOrgs[i]; importer.QueueNewEntry(tst); } importer.QueueNewDeletedEntry("patient", "31415"); var imported = importer.ImportQueued(); _store.AddEntries(imported); var recentList = _store.ListCollection("patient"); Assert.AreEqual(5, recentList.Count(), "Should not contain deleted entries"); var recentOrgList = _store.ListCollection("organization"); Assert.AreEqual(5, recentOrgList.Count(), "Should not contain patients"); recentList = _store.ListCollection("patient", includeDeleted: true); Assert.AreEqual(6, recentList.Count(), "Should contain deleted entries"); var recentListWithFilter = _store.ListCollection("patient", limit: 3); Assert.AreEqual(3, recentListWithFilter.Count()); var recentListWithFilter2 = _store.ListCollection("patient", since: now.AddMinutes(-1)); Assert.AreEqual(5, recentListWithFilter2.Count()); var recentListWithFilter3 = _store.ListCollection("patient", since: now.AddMinutes(-1), limit: 3); Assert.AreEqual(3, recentListWithFilter3.Count()); }