Exemplo n.º 1
0
        public void PutAsync_NullStream()
        {
            var storage = new FileBlobStorage(Configuration);

            storage
            .Awaiting(s => s.PutAsync(null, ".dat"))
            .Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 2
0
        public void DeleteAsync_NullUri()
        {
            var storage = new FileBlobStorage(Configuration);

            storage
            .Awaiting(s => s.DeleteAsync(null))
            .Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 3
0
        public void DeleteAsync_NotMyUri()
        {
            var storage = new FileBlobStorage(Configuration);
            var uri     = new Uri("some://other/base/file.txt");

            storage
            .Awaiting(s => s.DeleteAsync(uri))
            .Should().Throw <ArgumentException>();
        }
Exemplo n.º 4
0
        public void DeleteAsync_RelativeUri()
        {
            var storage = new FileBlobStorage(Configuration);
            var uri     = new Uri("relative/file.txt", UriKind.Relative);

            storage
            .Awaiting(s => s.DeleteAsync(uri))
            .Should().Throw <ArgumentException>();
        }
Exemplo n.º 5
0
        public void PutAsync_UnreadableStream()
        {
            var storage = new FileBlobStorage(Configuration);
            var stream  = Mock.Of <Stream>(s => s.CanRead == false);

            storage
            .Awaiting(s => s.PutAsync(stream, ".dat"))
            .Should().Throw <ArgumentException>();
        }
Exemplo n.º 6
0
        public void GetAsync_NotFound()
        {
            var storage = new FileBlobStorage(Configuration);
            var uri     = new Uri(storage.BaseUri, "does/not/exist.txt");

            storage
            .Awaiting(s => s.GetAsync(uri))
            .Should().Throw <IOException>();
        }
Exemplo n.º 7
0
        public void DeleteAsync_PathTooLong()
        {
            var storage = new FileBlobStorage(Configuration);
            var uri     = new Uri(storage.BaseUri, "a/b/file.txt");

            storage.FileSystem = FileSystem.Object;

            FileSystem
            .Setup(f => f.FileExists(It.IsAny <string>()))
            .Returns(true);

            FileSystem
            .Setup(f => f.DeleteFile(It.IsAny <string>()))
            .Throws <PathTooLongException>();    // should never happen, but coverage

            storage
            .Awaiting(s => s.DeleteAsync(uri))
            .Should().Throw <PathTooLongException>();
        }
Exemplo n.º 8
0
        public void DeleteAsync_Retry_Fail()
        {
            var storage = new FileBlobStorage(Configuration);
            var uri     = new Uri(storage.BaseUri, "a/b/file.txt");

            storage.FileSystem = FileSystem.Object;

            FileSystem
            .Setup(f => f.FileExists(It.IsAny <string>()))
            .Returns(true);

            FileSystem
            .Setup(f => f.DeleteFile(It.IsAny <string>()))
            .Throws <IOException>();

            storage
            .Awaiting(s => s.DeleteAsync(uri))
            .Should().Throw <IOException>();
        }
Exemplo n.º 9
0
        public void PutAsync_FileSystemChanged()
        {
            try
            {
                var storage = new FileBlobStorage(Configuration);
                var bytes   = Utf8.GetBytes(TestText);

                DeleteDirectory(@"");
                WriteFile(@"");        // same name as repository directory

                using (var stream = new MemoryStream(bytes))
                {
                    storage
                    .Awaiting(s => s.PutAsync(stream, ".txt"))
                    .Should().Throw <IOException>()
                    .Which.Message.Should().Contain("already exists");
                }
            }
            finally
            {
                DeleteFile(@"");
            }
        }