public async Task DeleteAsync_DoesNotExist() { var storage = new FileBlobStorage(Configuration); var uri = new Uri(storage.BaseUri, "a/b/file.txt"); var result = await storage.DeleteAsync(uri); result.Should().BeFalse(); }
public async Task DeleteAsync_Exists_DirectoryEmpty() { var storage = new FileBlobStorage(Configuration); var uri = new Uri(storage.BaseUri, "a/b/file.txt"); CreateDirectory(@"a", "b"); WriteFile(@"a", "b", "file.txt"); FileExists(@"a", "b", "file.txt").Should().BeTrue("file should exist prior to deletion"); var result = await storage.DeleteAsync(uri); result.Should().BeTrue(); FileExists(@"a", "b", "file.txt").Should().BeFalse("file should have been deleted"); DirectoryExists(@"a", "b").Should().BeFalse("empty subdirectory should have been deleted"); DirectoryExists(@"a").Should().BeFalse("empty subdirectory should have been deleted"); DirectoryExists(@"").Should().BeTrue("repository base directory should NOT have been deleted"); }
public async Task DeleteAsync_Retry_Succeed() { 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 .SetupSequence(f => f.DeleteFile(It.IsAny <string>())) .Throws <IOException>() .Pass(); var result = await storage.DeleteAsync(uri); result.Should().BeTrue(); }
public async Task DeleteAsync_DirectoryNotFound() { 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) .Verifiable(); FileSystem .Setup(f => f.DeleteFile(It.IsAny <string>())) .Throws <DirectoryNotFoundException>() .Verifiable(); // directory deleted after existence check var result = await storage.DeleteAsync(uri); result.Should().BeTrue(); FileSystem.Verify(); }