public void WavToMp3_NullDestination() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); string destination = tempDirPath.Combine(tempDirPath.Path, file); Assert.Throws <ArgumentNullException>(() => WavConverter.WavToMp3(destination, null), "WavToMp3 did not fail when it was given a null DestinationFilePath."); } }
public void WavToMp3_ConvertAndSaveSingleFiles() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); string destination = tempDirPath.Combine(tempDirPath.Path, file); WavConverter.WavToMp3(_goodWavFile, destination); Assert.IsTrue(File.Exists(destination), "WavConverter did not successfully convert the wav file and save it as an mp3 file."); } }
public void AlreadyExists_IdenticalExists() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); string destination = tempDirPath.Combine(tempDirPath.Path, file); WavConverter.WavToMp3(_goodWavFile, destination); Assert.IsTrue(WavConverter.AlreadyExists(_goodWavFile, destination) == SaveFile.IdenticalExists, "AlreadyExists did not recognize that the converted file already exists."); } }
public void WavToMp3_SourceDoesNotExist() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); string destination = tempDirPath.Combine(tempDirPath.Path, file); var ex = Assert.Throws <Exception>(() => WavConverter.WavToMp3(Path.Combine(_goodWavFile, "abcde.wav"), destination)); Assert.IsTrue(ex.Message.Equals("The source file path is invalid."), "WavToMp3 does not fail when it was given a nonexistent source."); } }
public void WavToMp3_NonExistentFolder() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string newDestination = tempDirPath.Combine(tempDirPath.Path, "New/new/abu2.mp3"); string directory = tempDirPath.Combine(tempDirPath.Path, "New"); WavConverter.WavToMp3(_goodWavFile, newDestination); Assert.IsTrue(Directory.Exists(directory), "SaveBytes did not create the previously nonexistent folder."); } }
public void WavToMp3_WrongExtension() { using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { string file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); string destination = tempDirPath.Combine(tempDirPath.Path, file); WavConverter.WavToMp3(_goodWavFile, destination); var ex = Assert.Throws <Exception>(() => WavConverter.WavToMp3(destination, destination)); Assert.IsTrue(ex.Message.Equals("Source file is not a .wav file."), "WavToMp3 did not fail when the source was not a .wav file."); } }
public void WavToMp3_ConvertAndSave_ReportsUnsupportedWav() { var messageBoxAdapter = new MockMessageBox(DialogResult.OK); MessageBoxUtils.Manager.SetMessageBoxAdapter(messageBoxAdapter); using (var tempDirPath = new TemporaryFolder(Path.GetRandomFileName())) { var file = Path.ChangeExtension(Path.GetRandomFileName(), ".mp3"); var destination = tempDirPath.Combine(tempDirPath.Path, file); Assert.DoesNotThrow(() => WavConverter.WavToMp3(_badWavFile, destination)); Assert.IsFalse(File.Exists(destination), "WavConverter should not have created an mp3 file."); Assert.AreEqual(1, messageBoxAdapter.MessagesDisplayed.Count); Assert.That(messageBoxAdapter.MessagesDisplayed[0], Is.StringStarting(string.Format(FwUtilsStrings.ConvertBytesToMp3_BadWavFile, file, string.Empty, string.Empty))); } }