public void PutAsync_NullStream() { var storage = new FileBlobStorage(Configuration); storage .Awaiting(s => s.PutAsync(null, ".dat")) .Should().Throw <ArgumentNullException>(); }
public void DeleteAsync_NullUri() { var storage = new FileBlobStorage(Configuration); storage .Awaiting(s => s.DeleteAsync(null)) .Should().Throw <ArgumentNullException>(); }
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>(); }
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>(); }
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>(); }
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>(); }
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>(); }
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>(); }
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(@""); } }