/// <summary> /// Ensures that the tool's process is unable to start. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenProcessCannotStart <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { fixture.ProcessRunner.Process = null; }
/// <summary> /// Ensures that the tool process exits with the given exit code. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="exitCode">The exit code.</param> public static void GivenProcessExitsWithCode <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture, int exitCode) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { fixture.ProcessRunner.Process.SetExitCode(exitCode); }
/// <summary> /// Ensures that gradleW does exist in the working directory /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="workDir">The directory to create the tool in.</param> public static void GivenGradleWExistIn <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture, DirectoryPath workDir) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } if (workDir == null) { throw new ArgumentNullException(nameof(workDir)); } var tool = fixture.Environment.Platform.Family == PlatformFamily.Windows ? "gradlew.bat" : "gradlew"; var file = fixture.FileSystem.GetFile( workDir.CombineWithFilePath(new FilePath(tool))); if (!file.Exists) { fixture.FileSystem.CreateFile(file.Path); } }
/// <summary> /// Ensures that the tool exist under the tool settings tool path. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenSettingsToolPathExist <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture.Settings.ToolPath != null) { var path = fixture.Settings.ToolPath.MakeAbsolute(fixture.Environment); fixture.FileSystem.CreateFile(path); } }
/// <summary> /// Ensures that the tool process exits with the given exit code. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="exitCode">The exit code.</param> public static void GivenProcessExitsWithCode <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture, int exitCode) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } fixture.ProcessRunner.Process.SetExitCode(exitCode); }
/// <summary> /// Ensures that the tool's process is unable to start. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenProcessCannotStart <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } fixture.ProcessRunner.Process = null; }
/// <summary> /// Ensures that the tool do not exist under the tool settings tool path. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenDefaultToolDoNotExist <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { var file = fixture.FileSystem.GetFile(fixture.DefaultToolPath); if (file.Exists) { file.Delete(); } }
/// <summary> /// Ensures that the tool does not exist under the tool settings tool path. /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenDefaultToolDoNotExist <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } var file = fixture.FileSystem.GetFile(fixture.DefaultToolPath); if (file.Exists) { file.Delete(); } }
/// <summary> /// Ensures that gradle.exe exist as a tool /// </summary> /// <typeparam name="TToolSettings">The type of the tool settings.</typeparam> /// <typeparam name="TFixtureResult">The type of the fixture result.</typeparam> /// <param name="fixture">The fixture.</param> public static void GivenGradleExeExistsAsADefaultTool <TToolSettings, TFixtureResult>( this ToolFixture <TToolSettings, TFixtureResult> fixture) where TToolSettings : ToolSettings, new() where TFixtureResult : ToolFixtureResult { if (fixture == null) { throw new ArgumentNullException(nameof(fixture)); } var defaultToolDir = fixture.DefaultToolPath.GetDirectory(); var gradleExe = defaultToolDir.CombineWithFilePath(new FilePath("gradle.exe")); var file = fixture.FileSystem.GetFile(gradleExe.FullPath); if (!file.Exists) { fixture.FileSystem.CreateFile(file.Path); } fixture.Tools.RegisterFile(file.Path); }