public void TestStoreStuffOnAmazon() { var s3 = new AmazonS3Storage(); s3.Open(); s3.DeleteAll(); var names = s3.ListNames(); Assert.AreEqual(0, names.Length); storeString(s3, "blob1", "Hello, world!"); storeString(s3, "blob2", "Gangnam style"); storeString(s3, "blob3", "All your base are belong to us"); names = s3.ListNames(); CollectionAssert.Contains(names, "blob1"); CollectionAssert.Contains(names, "blob2"); CollectionAssert.Contains(names, "blob3"); Assert.AreEqual(3, names.Length); s3.Delete("blob3"); names = s3.ListNames(); CollectionAssert.Contains(names, "blob1"); CollectionAssert.Contains(names, "blob2"); Assert.AreEqual(2, names.Length); s3.Delete("blob3"); // No exception, please names = s3.ListNames(); CollectionAssert.Contains(names, "blob1"); CollectionAssert.Contains(names, "blob2"); Assert.AreEqual(2, names.Length); storeString(s3, "blob3", "20 Return 10"); storeString(s3, "blob3", "10 Goto 20"); // No exception, please string contentType; byte[] data = s3.Fetch("blob3", out contentType); string output = Encoding.UTF8.GetString(data); Assert.AreEqual("10 Goto 20", output); names = s3.ListNames(); CollectionAssert.Contains(names, "blob1"); CollectionAssert.Contains(names, "blob2"); CollectionAssert.Contains(names, "blob3"); Assert.AreEqual(3, names.Length); s3.Close(); }
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 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")); } }