public void Should_Return_The_Number_Of_Paths_In_The_Collection() { // Given var collection = new DirectoryPathCollection( new[] { new DirectoryPath("A.txt"), new DirectoryPath("B.txt") }, new PathComparer(false)); // When, Then Assert.Equal(2, collection.Count); }
public void Should_Add_Paths_That_Are_Not_Present() { // Given var collection = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, new PathComparer(false)); // When collection.Add(new DirectoryPath[] { "A", "B", "C" }); // Then Assert.Equal(3, collection.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path(bool caseSensitive, int expectedCount) { // Given var collection = new DirectoryPathCollection(new PathComparer(caseSensitive)); collection.Add(new DirectoryPath("A")); // When collection.Add(new DirectoryPath("a")); // Then Assert.Equal(expectedCount, collection.Count); }
public void Should_Add_Path_If_Not_Already_Present() { // Given var collection = new DirectoryPathCollection(new PathComparer(false)); collection.Add(new DirectoryPath("B")); // When collection.Add(new DirectoryPath("A")); // Then Assert.Equal(2, collection.Count); }
public void Should_Return_New_Collection() { // Given var comparer = new PathComparer(false); var collection = new DirectoryPathCollection(comparer); var second = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, comparer); // When var result = collection + second; // Then Assert.False(ReferenceEquals(result, collection)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Paths() { // Given var comparer = new PathComparer(false); var collection = new DirectoryPathCollection(comparer); var second = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, comparer); // When var result = collection + second; // Then Assert.AreEqual(2, result.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path() { // Given var collection = new DirectoryPathCollection(new PathComparer(false)); collection.Add("B"); // When var result = collection + new DirectoryPath("A"); // Then Assert.AreEqual(2, result.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Path(bool caseSensitive, int expectedCount) { // Given var collection = new DirectoryPathCollection(new PathComparer(caseSensitive)); collection.Add(new DirectoryPath("A")); // When collection.Remove(new DirectoryPath("a")); // Then Assert.AreEqual(expectedCount, collection.Count); }
public void Should_Return_New_Collection() { // Given var collection = new DirectoryPathCollection(new PathComparer(false)); collection.Add("A"); collection.Add("B"); // When var result = collection - new DirectoryPath("A"); // Then Assert.False(ReferenceEquals(result, collection)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var collection = new DirectoryPathCollection(new PathComparer(caseSensitive)); collection.Add("A"); collection.Add("B"); collection.Add("C"); // When var result = collection - new[] { new DirectoryPath("b"), new DirectoryPath("c") }; // Then Assert.Equal(expectedCount, result.Count); }
public static void DeleteDirectories(this ICakeContext cakeContext, DeleteHelpersConfig config) { DirectoryPathCollection dirs = cakeContext.GetDirectories(config.FullDirectory.ToString()); List <DirectoryPath> orderedDirs = dirs.OrderBy(f => System.IO.Directory.GetCreationTime(f.ToString())).ToList(); while (orderedDirs.Count > config.NumberOfFilesToKeep) { DirectoryPath dir = orderedDirs[0]; cakeContext.Information($"Deleting '{dir}'"); if (config.DryRun == false) { DeleteDirectorySettings dirSettings = new DeleteDirectorySettings { Force = true, Recursive = true }; cakeContext.DeleteDirectory(dir, dirSettings); } orderedDirs.RemoveAt(0); } }
public StyleCopSettings() { Addins = new DirectoryPathCollection(new PathComparer(false)); }
public Build() { Task("Clean") .Does(() => { DirectoryPathCollection AllProj = Cake.GetDirectories("./*", p => !p.Path.FullPath.Contains("CodeCakeBuilder")); foreach (DirectoryPath proj in AllProj) { if (Cake.DirectoryExists(proj + "/bin")) { Cake.DeleteDirectory(proj + "/bin", true); } if (Cake.DirectoryExists(proj + "/obj")) { Cake.DeleteDirectory(proj + "/obj", true); } } }); Task("Restore") .IsDependentOn("Clean") .Does(() => { Cake.DotNetCoreRestore(); }); Task("Restore-Tools") .IsDependentOn("Restore") .Does(() => { DirectoryPath PackagesDir = new DirectoryPath("../packages"); DotNetCoreRestoreSettings dotNetCoreRestoreSettings = new DotNetCoreRestoreSettings(); dotNetCoreRestoreSettings.PackagesDirectory = PackagesDir; dotNetCoreRestoreSettings.ArgumentCustomization = args => args.Append("./CodeCakeBuilder/project.json"); Cake.DotNetCoreRestore(dotNetCoreRestoreSettings); }); Task("Build") .IsDependentOn("Restore-Tools") .Does(() => { DirectoryPathCollection AllProj = Cake.GetDirectories("./*", p => !p.Path.FullPath.Contains("CodeCakeBuilder")); foreach (DirectoryPath proj in AllProj) { Cake.DotNetCoreBuild(proj.FullPath); } }); Task("Unit-Tests") .IsDependentOn("Build") .Does(() => { FilePathCollection FilePathTests = Cake.GetFiles("./**/*.Tests.exe", p => Cake.FileExists(p.Path + "/nunit.framework.dll")); Cake.OpenCover(tool => { tool.NUnit3(FilePathTests, new NUnit3Settings { ToolPath = "../packages/NUnit.ConsoleRunner/3.5.0/tools/nunit3-console.exe" }); }, new FilePath("../resultOpenCover.xml"), new OpenCoverSettings { ToolPath = "../packages/OpenCover/4.6.519/tools/OpenCover.Console.exe", Register = "User" } .WithFilter("+[Test]*") .WithFilter("-[Test.Tests]*") ); }); // The Default task for this script can be set here. Task("Default") .IsDependentOn("Unit-Tests"); }
/// <summary> /// See <see cref="WithDirectoryContents{T}(T, DirectoryPath[])"/>. /// </summary> /// <typeparam name="T">the builder to support the <see cref="IHaveArgumentDirectories"/>.</typeparam> /// <param name="this">The builder-instance.</param> /// <param name="directories">The directories to operate on.</param> /// <returns>The builder, for fluent use.</returns> public static T WithDirectoryContents <T>(this T @this, DirectoryPathCollection directories) where T : ISupportArgumentBuilder <IHaveArgumentDirectories> { return(WithDirectoryContents(@this, directories.ToArray())); }
/// <summary> /// Creates a new instance of the StyleCopSettings class. /// </summary> public StyleCopSettings() { Addins = new DirectoryPathCollection(new PathComparer(false)); FailTask = true; OutputIssues = true; }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var collection = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, new PathComparer(caseSensitive)); // When collection.Remove(new DirectoryPath[] { "a", "b", "c" }); // Then Assert.Equal(expectedCount, collection.Count); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Path() { // Given var collection = new DirectoryPathCollection(new PathComparer(false)); collection.Add("B"); // When var result = collection + new DirectoryPath("A"); // Then Assert.Equal(2, result.Count); }
public void Should_Return_New_Collection() { // Given var collection = new DirectoryPathCollection(new PathComparer(false)); collection.Add("A"); collection.Add("B"); collection.Add("C"); // When var result = collection - new[] { new DirectoryPath("B"), new DirectoryPath("C") }; // Then Assert.False(ReferenceEquals(result, collection)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Paths() { // Given var comparer = new PathComparer(false); var collection = new DirectoryPathCollection(comparer); var second = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, comparer); // When var result = collection + second; // Then Assert.Equal(2, result.Count); }