Пример #1
0
        public void TrySave_Test_DoesNotCreateDestinationDirectoryGivenArtistThatExceedsMaxPathLimit()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Artist = exceedsMaxCharString;

                _systemFile.TrySave();

                var directoryExists = Directory.Exists($@"C:\_TempForTesting\{exceedsMaxCharString}\{album}\{song}");
                Assert.IsFalse(directoryExists);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #2
0
        public void TrySave_Test_FileExistsInNewLocationAfterValidArtistRename()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Artist = "Test Artist";

                _systemFile.TrySave();

                bool fileExistsInNewLocation = System.IO.File.Exists($@"C:\_TempForTesting\Test Artist\{album}\{song}");
                Assert.IsTrue(fileExistsInNewLocation);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #3
0
        public void TrySave_Test_FileDoesNotHaveOldNameAfterValidFileRename()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Title = "Test name";

                _systemFile.TrySave();

                var fileExistsWithOriginalName = System.IO.File.Exists($@"C:\_TempForTesting\{artist}\{album}\{song}");
                Assert.IsFalse(fileExistsWithOriginalName);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #4
0
        public void TrySave_Test_FileHasNewNameAfterValidFileRename()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Title = "Test name";

                _systemFile.TrySave();

                var fileExistsWithNewName = System.IO.File.Exists($@"C:\_TempForTesting\{artist}\{album}\Test name.mp3");
                Assert.IsTrue(fileExistsWithNewName);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #5
0
        public void TrySave_Test_FileIsMovedFromOriginalLocationAfterValidAlbumRename()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Album = "Test Album";

                _systemFile.TrySave();

                var fileExistsInOriginalLocation = System.IO.File.Exists($@"C:\_TempForTesting\{artist}\{album}\{song}");
                Assert.IsFalse(fileExistsInOriginalLocation);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #6
0
        public void IsUpdateNeeded_Test_ReturnsFalseWhenResponseHasSameValues()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir(FileTestSharedVariables.originalFilepath);
                var metadataFile      = GetMetadataFile();
                var gracenoteResponse = GetMatchingAPIResponse(metadataFile);
                metadataFile.Response = gracenoteResponse;

                var isUpdateNeeded = metadataFile.IsUpdateNeeded();

                Assert.IsFalse(isUpdateNeeded);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #7
0
        public void IsUpdateNeeded_Test_ReturnsTrueWhenResponseHasDifferentValues()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir(FileTestSharedVariables.originalFilepath);
                var metadataFile      = GetMetadataFile();
                var gracenoteResponse = GetAPIResponseWithDummyValues();
                metadataFile.Response = gracenoteResponse;

                var isUpdateNeeded = metadataFile.IsUpdateNeeded();

                Assert.IsTrue(isUpdateNeeded);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #8
0
        public void Equals_Test_ReturnsFalseGivenNonEqualMetadataFiles()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir(FileTestSharedVariables.originalFilepath);
                FileTestSharedVariables.CopyFileToTestDir(FileTestSharedVariables.copyOfOriginalFilepath);

                var metadataFile1 = GetMetadataFile();
                var metadataFile2 = GetMetadataFile(FileTestSharedVariables.copyOfOriginalFilepath);
                metadataFile2.Artist = "Something different";

                Assert.IsFalse(metadataFile1.Equals(metadataFile2));
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
        public void DeleteEmptyFolders_Test_NoDeletionsWhenParentFolderHasFiles()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                string testDirectory = Path.Combine(
                    FileTestSharedVariables.baseTestDirectory, @"Angels and Airwaves\We Don't Need to Whisper\");
                Directory.CreateDirectory(Path.Combine(testDirectory, @"Empty Bottom Folder\"));

                FileManipulator.DeleteEmptyFolders(new DirectoryInfo(testDirectory));

                bool testDirectoryExists = Directory.Exists(testDirectory);
                Assert.IsTrue(testDirectoryExists);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #10
0
        public void Equals_Test_ReturnsFalseGivenNotEqualSystemFile()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();

                var systemFile1 = GetSystemFile();
                var systemFile2 = GetSystemFile();
                systemFile2.Extension = ".SomeDifferentExtension";

                var areEqual = systemFile1.Equals(systemFile2);

                Assert.IsFalse(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #11
0
        public void TrySave_Test_MovesSuccesfullyWhenNewArtistNameOnlyDiffersByCase()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Artist = "aNgElS aNd AiRwAvEs";
                var originalFilepath = _systemFile.Filepath;

                _systemFile.TrySave();

                var  newFilePath = _systemFile.Filepath;
                bool areEqual    = (originalFilepath == newFilePath);
                Assert.IsFalse(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #12
0
        public void TrySave_Test_MovesSuccesfullyWhenNewAlbumNameOnlyDiffersByCase()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Album = "wE dOn'T nEeD tO wHiSpEr";
                var originalFilepath = _systemFile.Filepath;

                _systemFile.TrySave();

                var newFilePath = _systemFile.Filepath;
                var areEqual    = (originalFilepath == newFilePath);
                Assert.IsFalse(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #13
0
        public void UpdateMetadata_Test_MetadataFileDoesNotChangeGivenAnAPIResponseWithNoNewValues()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                var metadataFile           = GetMetadataFile();
                var propertiesBeforeUpdate = ExtractProperties(metadataFile);
                var gracenoteResponse      = GetMatchingAPIResponse(metadataFile);

                metadataFile.UpdateMetadata(gracenoteResponse);

                var propertiesAfterUpdate = ExtractProperties(metadataFile);
                var areEqual = AreEqual(propertiesBeforeUpdate, propertiesAfterUpdate);
                Assert.IsTrue(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #14
0
        public void UpdateMetadata_Test_SuccessfullyUpdatesMetadataFileGivenAnAPIResponseWithNewValues()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                var metadataFile           = GetMetadataFile();
                var propertiesBeforeUpdate = ExtractProperties(metadataFile);
                var gracenoteResponse      = GetAPIResponseWithDummyValues();

                metadataFile.UpdateMetadata(gracenoteResponse);

                var propertiesAfterUpdate = ExtractProperties(metadataFile);
                var areEqual = AreEqual(propertiesBeforeUpdate, propertiesAfterUpdate);
                Assert.IsFalse(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }
Пример #15
0
        public void TrySave_Test_RenamesSuccesfullyWhenNewFileNameOnlyDiffersByCase()
        {
            try
            {
                FileTestSharedVariables.CopyFileToTestDir();
                _systemFile = GetSystemFile();
                _systemFile.MetadataFile.Title = "tHe AdVeNtUrE";
                var originalFilepath = _systemFile.Filepath;

                _systemFile.TrySave();

                var newFilePath = _systemFile.Filepath;

                var areEqual = (originalFilepath == newFilePath);
                Assert.IsFalse(areEqual);
            }
            finally
            {
                FileTestSharedVariables.DeleteTestDirectory();
            }
        }