public void CreatePairShouldCreateInfoPairContainingBothInputs() { var fp = new Mock <IFilenamePicker>(); fp.Setup( m => m.GetFileName(It.IsAny <FileInfoCollector.FileInformations>(), It.IsAny <FileInfoCollector.FileInformations>())).Returns("asdf"); const string hash1 = "h"; const string hash2 = "hash"; var newFile = new FileInfoCollector.FileInformations() { FilePath = "fp1", Hash = hash1 }; var oldFile = new FileInfoCollector.FileInformations() { FilePath = "fp2", Hash = hash2 }; var pc = new PairCreator(fp.Object); var result = pc.CreatePair(newFile, oldFile); Assert.AreEqual(result.NewFileHash, hash1); Assert.AreEqual(result.OldFileHash, hash2); }
public void GetFileNameIfBothFilesProvidedAndAreDifferentThrowException() { var fp = SetupFilePicker(); const string path = "path"; const string differentPath = "differentPath"; var oldFile = new FileInfoCollector.FileInformations() { FilePath = path }; var newFile = new FileInfoCollector.FileInformations() { FilePath = differentPath }; var result = fp.GetFileName(newFile, oldFile); }
public void GetFileNameIfOnlyNewFileProvidedTakeFilenameFromItTest() { var fp = SetupFilePicker(); const string path = "path"; var input = new FileInfoCollector.FileInformations() { FilePath = path }; var result = fp.GetFileName(input, null); Assert.AreEqual(path, result); }
public void GetFileNameIfBothFilesProvidedAndAreSameTakeFromEither() { var fp = SetupFilePicker(); const string path = "path"; var oldFile = new FileInfoCollector.FileInformations() { FilePath = path }; var newFile = new FileInfoCollector.FileInformations() { FilePath = path }; var result = fp.GetFileName(newFile, oldFile); Assert.AreEqual(path, result); }
public void RevertShouldCreateEqualFileInfo() { const string filePath = @"C:/Folder/File"; const string hash = "abcd"; var converter = new LogLinesToFileInfoConverter(); var input = new FileInfoCollector.FileInformations() { FilePath = filePath, Hash = hash }; var expectedOutput = filePath + converter.Delimeter + hash; var result = converter.Revert(input); Assert.AreEqual(expectedOutput, result); }
public void CompareFileInfoReturnsTrueIfPathsAreSame() { var comparer = new CompareFileInfoOnPath(); const string path = "Path"; var info1 = new FileInfoCollector.FileInformations() { FilePath = path, Hash = "random1" }; var info2 = new FileInfoCollector.FileInformations() { FilePath = path, Hash = "random2" }; var expectedResult = true; var result = comparer.CompareInfo(info1, info2); Assert.AreEqual(result, expectedResult); }
public void RevertAllShouldProcessInput() { var converterMock = new Mock <ILogLineToFileInfoConverter>(); var expectedFileInfo = new FileInfoCollector.FileInformations() { FilePath = "dummy", Hash = "hash" }; converterMock.Setup(m => m.Convert(It.IsAny <string>())) .Returns(expectedFileInfo); var converter = new LogFileLinesFileInfoConverter(converterMock.Object); var input = new List <FileInfoCollector.FileInformations>() { new FileInfoCollector.FileInformations(), new FileInfoCollector.FileInformations() }; var result = converter.RevertAll(input); Assert.IsTrue(result.Count == 2); }
public void ConvertAllShouldReturnEmptyListOnEmptyInput() { var converterMock = new Mock <ILogLineToFileInfoConverter>(); var expectedFileInfo = new FileInfoCollector.FileInformations() { FilePath = "dummy", Hash = "hash" }; converterMock.Setup(m => m.Convert(It.IsAny <string>())) .Returns(expectedFileInfo); var converter = new LogFileLinesFileInfoConverter(converterMock.Object); var input = new List <string>() { }; var result = converter.ConvertAll(input); Assert.IsTrue(result.Count == 0); Assert.IsInstanceOfType(result, typeof(List <FileInfoCollector.FileInformations>)); }
public void PairShouldCorrectlyPairRightOnlyInput() { var pcMock = SetupBasicPairCreatorMock(); var infoComparerMock = SetupBasicInfoComparerMock(); var pairer = new InfoPairer(pcMock.Object, infoComparerMock.Object); var fileInfo = new FileInfoCollector.FileInformations() { FilePath = "path", Hash = "hash" }; List <FileInfoCollector.FileInformations> input1 = new List <FileInfoCollector.FileInformations>(); List <FileInfoCollector.FileInformations> input2 = new List <FileInfoCollector.FileInformations>() { fileInfo }; var result = pairer.Pair(input1, input2); Assert.IsInstanceOfType(result, typeof(List <InfoPair>)); Assert.IsTrue(result.Count == 1); Assert.AreEqual(result[0].OldFileHash, fileInfo.Hash); Assert.AreEqual(result[0].NewFileHash, null); }
public string Revert(FileInfoCollector.FileInformations fileInformations) { return(fileInformations.FilePath + Delimeter + fileInformations.Hash); }
public bool CompareInfo(FileInfoCollector.FileInformations info1, FileInfoCollector.FileInformations info2) { return(info1.FilePath.Equals(info2.FilePath)); }