public void ValidateJob_ThrowsExceptionBlankPass() { string expectedInnerError = "Remote Filesystem selected but credentials were invalid."; FindDuplicateOptions options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = false, Pass = "", User = "******", Path = @".\" }; FindDuplicatesJob testJob = new FindDuplicatesJob(options); Mock <IFileHelpers> fileHelperMock = new Moq.Mock <IFileHelpers>(); DuplicateFinder sut = new DuplicateFinder(fileHelperMock.Object); try { sut.ValidateJob(testJob); Assert.Fail("Should have thrown an argument exception"); } catch (ArgumentException ex) { Assert.True(ex.Message.Contains(expectedInnerError)); Assert.Pass(); } }
public void ValidateJob_ThrowsExceptionBlankUser() { FindDuplicateOptions options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = false, Pass = "******", User = "", Path = @".\" }; FindDuplicatesJob testJob = new FindDuplicatesJob(options); Mock <IFileHelpers> fileHelperMock = new Moq.Mock <IFileHelpers>(); DuplicateFinder sut = new DuplicateFinder(fileHelperMock.Object); try { sut.ValidateJob(testJob); Assert.Fail("Should have thrown an argument exception"); } catch (ArgumentException ex) { Assert.Pass(); } }
public void WalkFilePaths_ThrowsOnInvalidPath() { FindDuplicateOptions options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = true, Pass = "", User = "", Path = @".\" }; FindDuplicatesJob testJob = new FindDuplicatesJob(options); string expectedInnerError = "unanticipated error"; var filesystemMock = new Moq.Mock <IFileSystem>(); FileHelpers sut = new FileHelpers(filesystemMock.Object); filesystemMock .Setup(x => x.Directory.GetFiles(testJob.Options.Path, It.IsAny <string>(), It.IsAny <System.IO.SearchOption>())).Throws(new Exception(expectedInnerError)); try { sut.WalkFilePaths(testJob); Assert.Fail("If WalkFilePaths throws, there isn't anything we can do to recover. Should have thrown but did not."); } catch (Exception ex) { Assert.True(ex.Message.Contains(expectedInnerError)); Assert.Pass(); } }
public void WalkFilePaths_ReturnsExpectedArray() { FindDuplicateOptions options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = true, Pass = "", User = "", Path = @".\" }; FindDuplicatesJob testJob = new FindDuplicatesJob(options); string[] testFiles = new[] { @"C:\BOOTNXT", @"C:\hiberfil.sys", @"C:\pagefile.sys", @"C:\windows-version.txt" }; var filesystemMock = new Moq.Mock <IFileSystem>(); FileHelpers sut = new FileHelpers(filesystemMock.Object); filesystemMock.Setup(x => x.Directory.GetFiles(testJob.Options.Path, It.IsAny <string>(), It.IsAny <System.IO.SearchOption>())).Returns(testFiles); string[] actualResult = sut.WalkFilePaths(testJob); Assert.AreEqual(testFiles, actualResult); }
public void Setup() { _options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = true, Pass = "", User = "", Path = @".\" }; _testJob = new FindDuplicatesJob(_options); }
public void ValidateJob_IgnoresUserPassLocal() { FindDuplicateOptions options = new FindDuplicateOptions() { Domain = "", HashLimit = 0, IsLocalFileSystem = true, Pass = "", User = "", Path = @".\" }; FindDuplicatesJob testJob = new FindDuplicatesJob(options); Mock <IFileHelpers> fileHelperMock = new Moq.Mock <IFileHelpers>(); DuplicateFinder sut = new DuplicateFinder(fileHelperMock.Object); sut.ValidateJob(testJob); }
private string Write196_FindDuplicateOptions(FindDuplicateOptions v) { switch (v) { case FindDuplicateOptions.SameName: return "SameName"; case FindDuplicateOptions.SameSize: return "SameSize"; case FindDuplicateOptions.SameContent: return "SameContent"; } return XmlSerializationWriter.FromEnum((long) v, new string[] { "SameName", "SameSize", "SameContent" }, new long[] { 1L, 2L, 4L }, "Nomad.FileSystem.Virtual.FindDuplicateOptions"); }