public void Should_give_correct_filesystem_provider() { string firstProviderPath = ResourceHelpers.GetResourceDirectoryInfo("test_filesystem").FullName; string secondProviderPath = ResourceHelpers.GetResourceDirectoryInfo("another_filesystem").FullName; var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new FilesystemAdapterConfiguration { AdapterName = "test_filesystem", Directory = firstProviderPath }, new FilesystemAdapterConfiguration { AdapterName = "another_filesystem", Directory = secondProviderPath } } }); var firstProvider = sut.OpenDirectoryReference("enchilada://test_filesystem/"); firstProvider.Should().BeOfType <FilesystemDirectory>(); firstProvider.RealPath.Should().Be(firstProviderPath); var secondProvider = sut.OpenDirectoryReference("enchilada://another_filesystem/"); secondProvider.Should().BeOfType <FilesystemDirectory>(); secondProvider.RealPath.Should().Be(secondProviderPath); }
public async Task Should_list_all_nodes_at_root_2() { await ResourceHelpers.CreateFileWithContentAsync(ResourceHelpers.GetLocalDevelopmentContainer(), $"{Guid.NewGuid()}.txt", "stuff"); var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true } } }); var directory = sut.OpenDirectoryReference("enchilada://blob_filesystem"); var nodes = await directory.GetFilesAsync(); nodes.Count().Should().Be(1); await directory.DeleteAsync(); }
public void Should_throw_exception_if_uri_invalid() { var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new FilesystemAdapterConfiguration { AdapterName = "test_filesystem", Directory = ResourceHelpers.GetResourceDirectoryInfo().FullName } } }); Assert.Throws <UriFormatException>(() => sut.OpenDirectoryReference("abc")); }
public static EnchiladaMessageDataRepository Create(this IEnchiladaMessageDataRepositoryFactory factory, IEnchiladaAdapterConfiguration enchiladaAdapterConfiguration) { var enchiladaConfiguration = new EnchiladaConfiguration() { Adapters = new[] { enchiladaAdapterConfiguration } }; var enchiladaFileProviderResolver = new EnchiladaFileProviderResolver(enchiladaConfiguration); var baseUri = new Uri($"enchilada://{enchiladaAdapterConfiguration.AdapterName}"); return(factory.Create(enchiladaFileProviderResolver, baseUri)); }
public static IServiceCollection AddEnchilada(this IServiceCollection serviceCollection, EnchiladaBuilderOptions builderOptions) { var configurations = (from configuredAdapter in builderOptions.Adapters.GetChildren() let adapterTypes = GetAvailableEnchiladaAdapters(GetAssembliesToCheck(builderOptions)) let adapterProperties = configuredAdapter.GetChildren().ToList() let matchingFilesystemAdapter = GetEnchiladaAdapterType(configuredAdapter, adapterTypes) where (matchingFilesystemAdapter != null) && adapterProperties.Any(section => section.Key.ToLower() == "adapter") select CreateConfigurationInstance(matchingFilesystemAdapter, configuredAdapter, adapterProperties)).ToList(); var enchiladaFileProviderResolver = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = configurations }); serviceCollection.AddSingleton <IEnchiladaFilesystemResolver>(enchiladaFileProviderResolver); return(serviceCollection); }
public void Should_give_correct_blob_provider() { var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true }, new BlobStorageAdapterConfiguration { AdapterName = "another_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test123" }, new FilesystemAdapterConfiguration { AdapterName = "local_filesystem", Directory = "c:\\" }, } }); var firstProvider = sut.OpenDirectoryReference("enchilada://blob_filesystem/"); firstProvider.Should().BeOfType <BlobStorageDirectory>(); firstProvider.RealPath.Should().Be("http://127.0.0.1:10000/devstoreaccount1/test/"); var secondProvider = sut.OpenDirectoryReference("enchilada://another_filesystem/abc123/"); secondProvider.Should().BeOfType <BlobStorageDirectory>(); secondProvider.RealPath.Should().Be("http://127.0.0.1:10000/devstoreaccount1/test123/abc123/"); var thirdProvider = sut.OpenDirectoryReference("enchilada://local_filesystem/abc123/"); thirdProvider.Should().BeOfType <FilesystemDirectory>(); thirdProvider.RealPath.Should().Be("c:\\abc123"); }
public void Should_throw_exception_if_uri_invalid() { var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true } } }); Assert.Throws <UriFormatException>(() => sut.OpenFileReference("abc")); }
public void Should_allow_path_with_extension_in_name() { string filesystemPath = ResourceHelpers.GetResourceDirectoryInfo("test_filesystem").FullName; var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new FilesystemAdapterConfiguration { AdapterName = "test_filesystem", Directory = filesystemPath } } }); var provider = sut.OpenDirectoryReference("enchilada://test_filesystem/test.folder/"); provider.Should().BeOfType <FilesystemDirectory>(); provider.RealPath.Should().EndWith("test.folder"); }
public static IMessageDataRepository Create() { var directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + "\\"; var adapter = new FilesystemAdapterConfiguration() { AdapterName = "filesystem", Directory = directory }; var resolver = new EnchiladaFileProviderResolver(new EnchiladaConfiguration() { Adapters = new[] { adapter } }); var enchiladaMessageDataRepository = new EnchiladaMessageDataRepositoryFactory() .Create(resolver, new Uri("enchilada://filesystem")); return(enchiladaMessageDataRepository); }
public void Should_give_blob_provider() { var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true } } }); var directory = sut.OpenDirectoryReference("enchilada://blob_filesystem/"); directory.Should().BeOfType <BlobStorageDirectory>(); directory.RealPath.Should().Be("http://127.0.0.1:10000/devstoreaccount1/test/"); }
public When_transferring_between_filesystems() { providerResolver = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true }, new FilesystemAdapterConfiguration { AdapterName = "local_filesystem", Directory = ResourceHelpers.GetResourceDirectoryInfo().FullName } } }); }
public void Should_give_correct_blob_filesystem_provider() { var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true }, new BlobStorageAdapterConfiguration { AdapterName = "another_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test123" } } }); var firstProvider = sut.OpenFileReference("enchilada://blob_filesystem/SampleContent.txt"); firstProvider.Should().BeOfType <BlobStorageFile>(); firstProvider.RealPath.Should().Be("http://127.0.0.1:10000/devstoreaccount1/test/SampleContent.txt"); firstProvider.Name.Should().Be("SampleContent.txt"); var secondProvider = sut.OpenFileReference("enchilada://another_filesystem/SampleContent.txt"); secondProvider.Should().BeOfType <BlobStorageFile>(); secondProvider.RealPath.Should().Be("http://127.0.0.1:10000/devstoreaccount1/test123/SampleContent.txt"); secondProvider.Name.Should().Be("SampleContent.txt"); }
public void Should_throw_exception_when_no_configuration_provided() { var sut = new EnchiladaFileProviderResolver(); Assert.Throws <ConfigurationMissingException>(() => sut.OpenDirectoryReference("abc")); }