public async Task DirectoryDoesntExist() { string nonExistantDir = Path.Combine(TestSongsDir, "DoesntExist"); if (Directory.Exists(nonExistantDir)) { Directory.Delete(nonExistantDir, true); } Assert.IsFalse(Directory.Exists(nonExistantDir)); SongHasher <SongHashData> hasher = new SongHasher <SongHashData>(nonExistantDir); try { await hasher.HashDirectoryAsync().ConfigureAwait(false); Assert.Fail("Should have thrown exception."); } catch (DirectoryNotFoundException) { } catch (Exception ex) { Assert.Fail($"Expected {nameof(DirectoryNotFoundException)} but threw {ex.GetType().Name}"); } if (Directory.Exists(nonExistantDir)) { Directory.Delete(nonExistantDir, true); } }
public async Task HashAllSongs() { SongHasher <SongHashData> hasher = new SongHasher <SongHashData>(TestSongsDir); int newHashes = await hasher.HashDirectoryAsync().ConfigureAwait(false); Assert.AreEqual(newHashes, 7); }
public async Task HashCacheDoesntExist() { string nonExistantCacheFile = Path.Combine(TestCacheDir, "DoesntExist.dat"); SongHasher <SongHashData> hasher = new SongHasher <SongHashData>(TestSongsDir); int newHashes = await hasher.HashDirectoryAsync().ConfigureAwait(false); Assert.AreEqual(newHashes, 7); }
public async Task EmptyDirectory() { string emptyDir = Path.Combine(TestSongsDir, "EmptyDirectory"); DirectoryInfo dInfo = new DirectoryInfo(emptyDir); dInfo.Create(); Assert.AreEqual(0, dInfo.GetFiles().Count()); SongHasher <SongHashData> hasher = new SongHasher <SongHashData>(emptyDir); int newHashes = await hasher.HashDirectoryAsync().ConfigureAwait(false); Assert.AreEqual(0, newHashes); //Clean up if (dInfo.Exists) { dInfo.Delete(true); } }