示例#1
0
        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);
            }
        }
示例#2
0
        public async Task HashAllSongs()
        {
            SongHasher <SongHashData> hasher = new SongHasher <SongHashData>(TestSongsDir);
            int newHashes = await hasher.HashDirectoryAsync().ConfigureAwait(false);

            Assert.AreEqual(newHashes, 7);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
            }
        }