public void Test_Creation_Of_List_Handles_Differences_Correctly() { var mockIo = Substitute.For <IIO>(); mockIo.DirectoryExist(Arg.Any <string>()).Returns(true); // Irrelevant at this point mockIo.GetFiles("a", "*", true).Returns(new List <string> { @"a\a_only.txt", @"a\sub\common.txt", }); mockIo.GetFiles("b", "*", true).Returns(new List <string> { @"b\b_only.txt", @"b\sub\common.txt", }); var list = new FileGatherer(mockIo, "a", "b").CreateFilelist().ToList(); Assert.That(list, Has.Count.EqualTo(3), "Expect three entries found"); Assert.That(list.FirstOrDefault(l => l.CommonName.Contains("a_only")), Has.Property(nameof(CompareEntry.PathB)).Null, "a_only must exist only on the item 1 side"); Assert.That(list.FirstOrDefault(l => l.CommonName.Contains("b_only")), Has.Property(nameof(CompareEntry.PathA)).Null, "b_only must exist only on the item 2 side"); Assert.That(list.FirstOrDefault(l => l.PathA != null && l.PathB != null), Has.Property(nameof(CompareEntry.CommonName)).Contains("common"), "b_only must exist only on the item 2 side"); }
public void SetUp() { _mockDirectoryProvider = new Mock <IDirectoryProvider>(); _mockFileNameParser = new Mock <IFileNameParser>(); _testDate = new DateTime(2017, 6, 9); _testFolderPath = @"m:\u_ex170608.log"; _testLogFilePaths = new[] { @"m:\u_ex170608.log", @"m:\u_ex170608.txt", @"m:\u_ex20170608.log" }; _mockDirectoryProvider .Setup(dp => dp.GetFiles(It.Is <string>(s => s == _testFolderPath))) .Returns(_testLogFilePaths); cut = new FileGatherer(_mockDirectoryProvider.Object, _mockFileNameParser.Object); }
private async Task SearchForFiles() { // create new instance of Cancel-token for each search cancel = new CancellationTokenSource(); SearchProfile profile = new SearchProfile(InputSearchString, InputExtension); FileGatherer gatherer = new FileGatherer(SourceDirectories, profile); await gatherer.TraverseSourceDirs(cancel.Token); var result = gatherer.GetFoundFiles(); ObservableCollection <HitFile> localHits = new ObservableCollection <HitFile>(); foreach (var file in result) { localHits.Add(file); } HitList = localHits; }