Beispiel #1
0
        public void TestUseAndPurgeBatch()
        {
            _store.EraseData();

            _store.AddEntries(_stockPatients.Take(10));
            var result = _store.ListCollection("patient");

            Assert.AreEqual(10, result.Count());
            _store.EraseData();

            Guid batchGuid = Guid.NewGuid();

            _store.AddEntry(_stockPatients[0], batchId: batchGuid);
            _store.AddEntry(_stockPatients[1], batchId: batchGuid);
            result = _store.ListCollection("patient");
            Assert.AreEqual(2, result.Count());
            _store.PurgeBatch(batchGuid);
            result = _store.ListCollection("patient");
            Assert.AreEqual(0, result.Count());

            batchGuid = Guid.NewGuid();
            _store.AddEntries(_stockPatients.Take(10), batchGuid);
            _store.PurgeBatch(batchGuid);
            result = _store.ListCollection("patient");
            Assert.AreEqual(0, result.Count());
        }
Beispiel #2
0
        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"));
            }
        }