public void Should_Find_Inspect_Code_Runner() { // Given var fixture = new DupFinderRunnerFixture(); // When var result = fixture.Run(); // Then Assert.Equal("/Working/tools/dupfinder.exe", result.Path.FullPath); }
public void Should_Set_Caches_Home() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.CachesHome = DirectoryPath.FromString("caches/"); // Then var result = fixture.Run(); // Then Assert.Equal("\"/caches-home=/Working/caches\" \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Normalize_Types_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.NormalizeTypes = true; // Then var result = fixture.Run(); // Then Assert.Equal("/normalize-types \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Show_Text_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.ShowText = true; // Then var result = fixture.Run(); // Then Assert.Equal("/show-text \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Exclude_By_Comment() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.ExcludeFilesByStartingCommentSubstring = new[] { "test", "test1" }; // Then var result = fixture.Run(); // Then Assert.Equal("\"/exclude-by-comment=test;test1\" \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Idle_Priority_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.IdlePriority = true; // Then var result = fixture.Run(); // Then Assert.Equal("/idle-priority \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Discard_Local_Vars_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.DiscardLocalVariablesName = true; // Then var result = fixture.Run(); // Then Assert.Equal("/discard-local-vars \"/Working/Test.sln\"", result.Args); }
public void Should_Throw_If_Files_Are_Null() { // Given var fixture = new DupFinderRunnerFixture(); fixture.FilePaths = null; // When var result = Record.Exception(() => fixture.Run()); // Then Assert.IsArgumentNullException(result, "filePaths"); }
public void Should_Set_Discard_Literals_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.DiscardLiterals = true; // Then var result = fixture.Run(); // Then Assert.Equal("/discard-literals \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Discard_Cost() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.DiscardCost = 50; // Then var result = fixture.Run(); // Then Assert.Equal("/discard-cost=50 \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Debug_Switch() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.Debug = true; // Then var result = fixture.Run(); // Then Assert.Equal("/debug \"/Working/Test.sln\"", result.Args); }
public void Should_Set_Exclude_Pattern() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.ExcludePattern = new[] { "*Tests.cs", "*Test.cs" }; // Then var result = fixture.Run(); // Then Assert.Equal("\"/exclude=*Tests.cs;*Test.cs\" \"/Working/Test.sln\"", result.Args); }
public void Should_Throw_If_OutputFile_Contains_Duplicates_And_Set_To_Throw() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.OutputFile = new FilePath("build/duplicates.xml"); fixture.Settings.ThrowExceptionOnFindingDuplicates = true; // When var result = Record.Exception(() => fixture.Run()); // Then Assert.IsCakeException(result, "Duplicates found in code base."); }
public void Should_Set_Exclude_Code_Regions() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.ExcludeCodeRegionsByNameSubstring = new[] { "generated code", "test" }; // Then var restult = fixture.Run(); // Then Assert.Equal("\"/exclude-code-regions=generated code;test\" " + "\"/Working/Test.sln\"", restult.Args); }
public void Should_Set_Output_File() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.OutputFile = new FilePath("build/dupfinder.xml"); // Then var result = fixture.Run(); // Then Assert.Equal("\"/output=/Working/build/dupfinder.xml\" " + "\"/Working/Test.sln\"", result.Args); }
public void Should_Throw_If_Process_Was_Not_Started() { // Given var fixture = new DupFinderRunnerFixture(); fixture.GivenProcessCannotStart(); // When var result = Record.Exception(() => fixture.Run()); // Then Assert.IsType <CakeException>(result); Assert.Equal("DupFinder: Process was not started.", result.Message); }
public void Should_Throw_If_Has_A_Non_Zero_Exit_Code() { // Given var fixture = new DupFinderRunnerFixture(); fixture.GivenProcessExitsWithCode(1); // When var result = Record.Exception(() => fixture.Run()); // Then Assert.IsType <CakeException>(result); Assert.Equal("DupFinder: Process returned an error (exit code 1).", result.Message); }
public void Should_Use_Provided_Files_In_Process_Arguments() { // Given var fixture = new DupFinderRunnerFixture(); fixture.FilePaths.Clear(); fixture.FilePaths.Add(new FilePath("./Test.sln")); fixture.FilePaths.Add(new FilePath("./Test.csproj")); // When var result = fixture.Run(); // Then Assert.Equal("\"/Working/Test.sln\" \"/Working/Test.csproj\"", result.Args); }
public void Should_Set_MSBuild_Properties() { // Given var fixture = new DupFinderRunnerFixture(); fixture.Settings.MsBuildProperties = new Dictionary <string, string>(); fixture.Settings.MsBuildProperties.Add("TreatWarningsAsErrors", "true"); fixture.Settings.MsBuildProperties.Add("Optimize", "false"); // Then var result = fixture.Run(); // Then Assert.Equal("\"/properties:TreatWarningsAsErrors=true\" " + "\"/properties:Optimize=false\" " + "\"/Working/Test.sln\"", result.Args); }
public void Should_Analyze_Output() { var log = new FakeLog(); // Given var fixture = new DupFinderRunnerFixture { Log = log }; fixture.Settings.OutputFile = new FilePath("build/duplicates.xml"); // When fixture.Run(); // Then var logContainsInspectionResults = log.Entries.Any(p => p.Message.StartsWith("Duplicate Located with a cost of")); Assert.True(logContainsInspectionResults); }