public void TestGetSubDirectoriesAndFiles() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("forms/form_123/kitty.jpg", Stream.Null); provider.AddFile("forms/form_123/dog.jpg", Stream.Null); provider.AddFile("forms/form_456/panda.jpg", Stream.Null); // Act var subfolders = provider.GetDirectories("forms"); var actual = new List <string>(); foreach (var folder in subfolders) { // Get files in subfolder and add to a single collection actual.AddRange(provider.GetFiles(folder)); } // Assert string[] expected = { "forms/form_123/dog.jpg", "forms/form_123/kitty.jpg", "forms/form_456/panda.jpg" }; Assert.IsTrue(expected.SequenceEqual(actual)); // Tidy up after test provider.DeleteDirectory("forms"); }
public void InsuffientSasTokenPermissions() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(containerName: "xxx", useDefaultRoute: "false"); // Act & Assert Assert.Throws <Microsoft.WindowsAzure.Storage.StorageException>(() => provider.AddFile("1010/image.jpg", Stream.Null)); }
protected void CreateSut() { Sut = new AzureBlobFileSystem( MockRepository.GenerateStub <ILogger>(), Account, ContainerName, BlobUrl ); }
protected void CreateSut() { Sut = new AzureBlobFileSystem( MockRepository.GenerateStub<ILogger>(), Account, ContainerName, BlobUrl ); }
public void TestValidDirectory() { AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("testvalid/test.txt", Stream.Null); Assert.IsTrue(provider.DirectoryExists("testvalid")); // Tidy up after test provider.DeleteDirectory("testvalid"); }
public void ResolveUrlPrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act string actual = provider.GetUrl($"{this.ContainerName}/110/image.jpg"); // Assert Assert.AreEqual($"/{this.ContainerName}/110/image.jpg", actual); }
public void ResolveFullPathPrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act string actual = provider.GetFullPath("media/1010/media.jpg"); // Assert Assert.AreEqual("http://127.0.0.1:10000/devstoreaccount1/media/1010/media.jpg", actual); }
public void ResolveRelativePath() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act string actual = provider.GetRelativePath("1010/media.jpg"); // Assert Assert.AreEqual("/media/1010/media.jpg", actual); }
public void ResolveFullPath() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act string actual = provider.GetFullPath("1010/image.jpg"); // Assert Assert.AreEqual($"{this.RootUrl}{this.ContainerName}/1010/image.jpg", actual); }
public void TestGetFilesInvalidPath() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act IEnumerable <string> actual = provider.GetFiles("/somethingmissing", "*.jpg"); // Assert Assert.IsEmpty(actual); }
public void TestAddFilePrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile($"{this.ContainerName}/1010/image.jpg", Stream.Null); // Assert Assert.IsTrue(provider.FileExists("1010/image.jpg")); }
public void ResolveRelativePathWithAppVirtualPath() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(false, "/test"); // Act string actual = provider.GetRelativePath("1010/image.jpg"); // Assert Assert.AreEqual($"/test/{this.ContainerName}/1010/image.jpg", actual); }
public void ResolveUrlPrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act string actual = provider.GetUrl("media/1010/media.jpg"); // Assert Assert.AreEqual("/media/1010/media.jpg", actual); }
public void TestAddFilePrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile("media/1010/media.jpg", Stream.Null); // Assert Assert.IsTrue(provider.FileExists("1010/media.jpg")); }
public void TestFileExists() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile("1010/image.jpg", Stream.Null); // Assert Assert.IsTrue(provider.FileExists("1010/image.jpg")); Assert.IsFalse(provider.FileExists("1010/media1.jpg")); }
public AzureFS(string inputConnectionString) { _inputFS = _azure; if (String.IsNullOrEmpty(inputConnectionString)) { throw new ArgumentNullException(nameof(inputConnectionString)); } _inputFS.AddStorageAccount("azure", inputConnectionString); _inputFS.SetWorkingFolder("wasb://azure/web"); }
public void SuffientSasTokenPermissions() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(containerName: "xxx", useDefaultRoute: "false"); // Act provider.AddFile("1010/image.jpg", Stream.Null); // Assert Assert.IsTrue(provider.FileExists("1010/image.jpg")); Assert.IsFalse(provider.FileExists("1010/media1.jpg")); }
public void TestGetFiles() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("1010/media.jpg", Stream.Null); // Act IEnumerable <string> actual = provider.GetFiles("/1010"); // Assert string[] expected = { "1010/media.jpg" }; Assert.IsTrue(expected.SequenceEqual(actual)); }
public void TestGetDirectoriesPrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile($"{this.ContainerName}/1010/image.jpg", Stream.Null); provider.AddFile($"{this.ContainerName}/1011/image.jpg", Stream.Null); provider.AddFile($"{this.ContainerName}/1012/image.jpg", Stream.Null); // Act IEnumerable <string> actual = provider.GetDirectories("/"); // Assert string[] expected = { "1010", "1011", "1012" }; Assert.IsTrue(expected.SequenceEqual(actual)); }
public void TestOpenFilePrefixed() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); using (MemoryStream expected = new MemoryStream(Encoding.UTF8.GetBytes("test"))) { // Act provider.AddFile("media/1010/media.jpg", expected); // Assert using (Stream actual = provider.OpenFile("media/1010/media.jpg")) { Assert.AreEqual(expected, actual); } } }
public AzureFS(string inputConnectionString, string container) { _inputFS = _azure; if (String.IsNullOrEmpty(inputConnectionString)) { throw new ArgumentNullException(nameof(inputConnectionString)); } if (container == null) { throw new ArgumentNullException(nameof(container)); } _inputFS.AddStorageAccount("azure", inputConnectionString); _inputFS.SetWorkingFolder($"wasb://azure/{container}"); }
public void TestGetFilesFromRootFiltered() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("1010/media.jpg", Stream.Null); provider.AddFile("1011/media.jpg", Stream.Null); provider.AddFile("1012/media.jpg", Stream.Null); // Act IEnumerable <string> actual = provider.GetFiles("/", "*.jpg"); IEnumerable <string> alternate = provider.GetFiles("/", "*.png"); // Assert string[] expected = { "1010/media.jpg", "1011/media.jpg", "1012/media.jpg" }; Assert.IsTrue(expected.SequenceEqual(actual)); Assert.IsFalse(expected.SequenceEqual(alternate)); }
public AzureFS(string inputConnectionString, string outputConnectionString) { _inputFS = _azure; _outputFS = _azure; if (String.IsNullOrEmpty(inputConnectionString)) { throw new ArgumentNullException(nameof(inputConnectionString)); } if (String.IsNullOrEmpty(outputConnectionString)) { throw new ArgumentNullException(nameof(outputConnectionString)); } _inputFS.AddStorageAccount("input", inputConnectionString); _outputFS.AddStorageAccount("output", outputConnectionString); }
public void TestDeleteDirectory() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile("1010/image.jpg", Stream.Null); // Assert Assert.IsTrue(provider.DirectoryExists("1010/")); // Act provider.DeleteDirectory("1010/"); // Assert Assert.IsFalse(provider.DirectoryExists("1010/")); Assert.IsFalse(provider.FileExists("1010/image.jpg")); }
public void TestDeleteDirectoryRelative() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile("media/1010/media.jpg", Stream.Null); // Assert Assert.IsTrue(provider.DirectoryExists("media/1010")); // Act provider.DeleteDirectory("\\media\\1010"); // Assert Assert.IsFalse(provider.DirectoryExists("media/1010/")); Assert.IsFalse(provider.FileExists("media/1010/media.jpg")); }
public void TestDeleteDirectoryRelative() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); // Act provider.AddFile($"{this.ContainerName}/1010/image.jpg", Stream.Null); // Assert Assert.IsTrue(provider.DirectoryExists($"{this.ContainerName}/1010")); // Act provider.DeleteDirectory($"\\{this.ContainerName}\\1010"); // Assert Assert.IsFalse(provider.DirectoryExists($"{this.ContainerName}/1010/")); Assert.IsFalse(provider.FileExists($"{this.ContainerName}/1010/image.jpg")); }
public void Run(string inputStorageAccount, string queueStorageAccount, string queueName) { _inputStorageAccount = inputStorageAccount; _queueStorageAccount = queueStorageAccount; _queueName = queueName; var input = new AzureBlobFileSystem(); input.AddStorageAccount("input", inputStorageAccount); input.SetWorkingFolder("wasb://input"); var container = input.GetFolder("pdf"); var itens = container.EnumItems(); var itens_added = ProcessItensAsync(itens, "pdf").GetAwaiter().GetResult(); Console.WriteLine($"{itens_added} message(s) added to the queue !"); }
static void Main(string[] args) { Console.WriteLine("Console Queue"); _config = new Config(args); var input = new AzureBlobFileSystem(); input.AddStorageAccount("input", _config.Get("INPUT_STORAGE_ACCOUNT")); input.SetWorkingFolder("wasb://input"); var container = input.GetFolder("pdf"); var itens = container.EnumItems(); var itens_added = ProcessItensAsync(itens, "pdf").GetAwaiter().GetResult(); Console.WriteLine($"{itens_added} message(s) added to the queue !"); }
public void TestGetSubDirectories() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("forms/form_123/kitty.jpg", Stream.Null); provider.AddFile("forms/form_123/dog.jpg", Stream.Null); provider.AddFile("forms/form_456/panda.jpg", Stream.Null); // Act IEnumerable <string> actual = provider.GetDirectories("forms"); // Assert string[] expected = { "forms/form_123", "forms/form_456" }; Assert.IsTrue(expected.SequenceEqual(actual)); // Tidy up after test provider.DeleteDirectory("forms"); }
public void TestGetCreated() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("1010/media.jpg", Stream.Null); // Act DateTimeOffset original = provider.GetCreated("1010/media.jpg"); // Assert Assert.AreNotEqual(original, DateTimeOffset.MinValue); // Act provider.AddFile("1010/media.jpg", Stream.Null); DateTimeOffset updated = provider.GetCreated("1010/media.jpg"); // Assert Assert.AreEqual(original, updated); }
public void TestGetLastModified() { // Arrange AzureBlobFileSystem provider = this.CreateAzureBlobFileSystem(); provider.AddFile("1010/media.jpg", Stream.Null); // Act DateTimeOffset original = provider.GetLastModified("1010/media.jpg"); // Assert Assert.AreNotEqual(original, DateTimeOffset.MinValue); Thread.Sleep(TimeSpan.FromSeconds(1.1)); // Act provider.AddFile("1010/media.jpg", Stream.Null); DateTimeOffset updated = provider.GetLastModified("1010/media.jpg"); // Assert Assert.AreNotEqual(original, updated); }