示例#1
0
        public async void File_Stored_EqualToInputFile()
        {
            await Lock(async() =>
            {
                var inputFile  = new TestFile(_inputDirectoryPath, _inputFileName, 5);
                var outputFile = new TestFile(_outputDirectoryPath, _outputFileName, 5);

                IStorageProvider storage = new AzureStorageProvider(Configuration);
                using (var source = new FileStream(inputFile.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    await storage.Store(outputFile.Dir, outputFile.Name, source);

                    using (var destination = storage.Get(outputFile.Dir, outputFile.Name))
                    {
                        source.Position      = 0;
                        destination.Position = 0;

                        var inputData  = new byte[source.Length];
                        var outputData = new byte[destination.Length];

                        source.Read(inputData, 0, (int)source.Length);
                        destination.Read(outputData, 0, (int)destination.Length);

                        Assert.Equal(source.Length, destination.Length);
                        Assert.Equal(inputData, outputData);
                    }
                }

                await storage.Remove(outputFile.Dir, outputFile.Name);
            });
        }
示例#2
0
        public AzureStorageProviderTests()
        {
            var fileSettings = A.Fake <IFileSettings>();

            _blobStoreFactory     = A.Fake <IBlobStoreFactory>();
            _azureStorageProvider = new AzureStorageProvider(fileSettings, _blobStoreFactory);
        }
        public HealthCheckFacet BlobStorage()
        {
            var azureBlobProvider = new AzureStorageProvider("blobs", string.Empty);

            return(new HealthCheckFacet
            {
                Name = "BlobStorage",
                Healthy = azureBlobProvider.CanConnect(),
            });
        }
示例#4
0
        public void Put_integration_test()
        {
            var fileSettings     = A.Fake <IFileSettings>();
            var containerBuilder = new ContainerBuilder();
            var azureModule      = new Azure.Module();

            azureModule.RegisterComponents(containerBuilder);
            var container            = containerBuilder.Build();
            var azureStorageProvider = new AzureStorageProvider(fileSettings, container.Resolve <IBlobStoreFactory>());

            azureStorageProvider.Put("test", "filename.txt", "test", "text/plain");
        }
 public BlobTestBase(StorageFixture fixture)
 {
     _fixture  = fixture;
     _client   = fixture._client;
     _provider = new AzureStorageProvider(new AzureProviderOptions
     {
         ConnectionString = fixture.Config["ConnectionString"],
     });
     _exceptionProvider = new AzureStorageProvider(new AzureProviderOptions
     {
         ConnectionString = "DefaultEndpointsProtocol=https;AccountName=aaa;AccountKey=bG9sd3V0",
     });
 }
示例#6
0
        public async void FileAsPath_Stored_Exists()
        {
            await Lock(async() =>
            {
                var inputFile  = new TestFile(_inputDirectoryPath, _inputFileName, 3);
                var outputFile = new TestFile(_outputDirectoryPath, _outputFileName, 3);

                IStorageProvider storage = new AzureStorageProvider(Configuration);

                await storage.Store(outputFile.Dir, outputFile.Name, inputFile.Path);
                var outFile = storage.Get(outputFile.Dir, outputFile.Name);

                Assert.NotNull(outFile);
                await storage.Remove(outputFile.Dir, outputFile.Name);
            });
        }
示例#7
0
        public async void File_Removed_DoesntExist()
        {
            await Lock(async() =>
            {
                var inputFile  = new TestFile(_inputDirectoryPath, _inputFileName, 4);
                var outputFile = new TestFile(_outputDirectoryPath, _outputFileName, 4);

                IStorageProvider storage = new AzureStorageProvider(Configuration);

                await storage.Store(outputFile.Dir, outputFile.Name, inputFile.Path);
                await storage.Remove(outputFile.Dir, outputFile.Name);

                Assert.ThrowsAny <Exception>(() =>
                {
                    var outFile = storage.Get(outputFile.Dir, outputFile.Name);
                    Assert.Null(outFile);
                });
            });
        }
示例#8
0
        public async void FileAsStream_Stored_Exists()
        {
            await Lock(async() =>
            {
                var inputFile  = new TestFile(_inputDirectoryPath, _inputFileName, 1);
                var outputFile = new TestFile(_outputDirectoryPath, _outputFileName, 1);

                IStorageProvider storage = new AzureStorageProvider(Configuration);

                using (var source = new FileStream(inputFile.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    await storage.Store(outputFile.Dir, outputFile.Name, source);
                    var outFile = storage.Get(outputFile.Dir, outputFile.Name);

                    Assert.NotNull(outFile);
                }

                await storage.Remove(outputFile.Dir, outputFile.Name);
            });
        }
示例#9
0
        public async void FileAsBytes_Stored_Exists()
        {
            await Lock(async() =>
            {
                var inputFile  = new TestFile(_inputDirectoryPath, _inputFileName, 2);
                var outputFile = new TestFile(_outputDirectoryPath, _outputFileName, 2);

                byte[] fileData = null;

                using (var file = new FileStream(inputFile.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    fileData = new byte[file.Length];
                    file.Read(fileData, 0, (int)file.Length);
                }

                IStorageProvider storage = new AzureStorageProvider(Configuration);

                await storage.Store(outputFile.Dir, outputFile.Name, fileData);
                var outFile = storage.Get(outputFile.Dir, outputFile.Name);
                Assert.NotNull(outFile);

                await storage.Remove(outputFile.Dir, outputFile.Name);
            });
        }
 public ListFilesModel(AzureStorageProvider azureStorageService,
                       FileDescriptionProvider fileDescriptionProvider)
 {
     _azureStorageService     = azureStorageService;
     _fileDescriptionProvider = fileDescriptionProvider;
 }
示例#11
0
 public ValuesController(AzureStorageProvider azureStorageProvider)
 {
     _azureStorageProvider = azureStorageProvider;
 }