Ejemplo n.º 1
0
        public async Task Should_give_stream()
        {
            string fileName = $"{Guid.NewGuid()}.txt";
            await ResourceHelpers.CreateFileWithContentAsync(ResourceHelpers.GetLocalDevelopmentContainer(), fileName, FileContent);

            var sut = new BlobStorageFile(ResourceHelpers.GetLocalDevelopmentContainer(), fileName);

            using (var stream = await sut.OpenReadAsync())
            {
                stream.Should().NotBe(null);
                stream.Position.Should().Be(0);
            }

            await sut.DeleteAsync();
        }
Ejemplo n.º 2
0
        public async Task Should_be_able_to_read_file_contents_from_stream()
        {
            string fileName = $"{Guid.NewGuid()}.txt";
            await ResourceHelpers.CreateFileWithContentAsync(ResourceHelpers.GetLocalDevelopmentContainer(), fileName, FileContent);

            var sut = new BlobStorageFile(ResourceHelpers.GetLocalDevelopmentContainer(), fileName);

            using (var stream = await sut.OpenReadAsync())
                using (var reader = new StreamReader(stream))
                {
                    string content = await reader.ReadToEndAsync();

                    content.Should().NotBeEmpty();
                    content.Should().StartWith(FileContent);
                }

            await sut.DeleteAsync();
        }