/// <summary> /// Initializes a new instance of the <see cref="FakeEnvironment"/> class. /// </summary> /// <param name="family">The platform family.</param> /// <param name="is64Bit">if set to <c>true</c>, the platform is 64 bit.</param> public FakeEnvironment(PlatformFamily family, bool is64Bit = true) { Platform = new FakePlatform(family, is64Bit); Runtime = new FakeRuntime(); _environmentVariables = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); _specialPaths = new Dictionary <SpecialPath, DirectoryPath>(); }
public CakeContext CreateContext(PlatformFamily platform) { Environment.Platform.Family.Returns(platform); return(new CakeContext(FileSystem, Environment, Globber, Log, Arguments, ProcessRunner, Registry, Tools, DataService, Configuration)); }
protected void SetValidPlatforms(PlatformFamily validPlatformFamily) { switch (validPlatformFamily) { case PlatformFamily.Unix: ValidPlatforms = UnixFamily; break; default: ValidPlatforms = WindowsFamily; break; } }
public void Should_Return_Correct_Value(PlatformFamily family, bool expected) { // Given var context = Substitute.For <ICakeContext>(); context.Environment.Returns(new FakeEnvironment(family)); // When var result = EnvironmentAliases.IsRunningOnMacOs(context); // Then Assert.Equal(expected, result); }
public ProtoCompileToolResolverFixture(PlatformFamily family, bool is64Bit) { Environment = Substitute.For <ICakeEnvironment>(); Environment.Platform.Returns(info => { var platform = Substitute.For <ICakePlatform>(); platform.Is64Bit.Returns(is64Bit); platform.Family.Returns(family); return(platform); }); FileSystem = Substitute.For <IFileSystem>(); ToolLocator = Substitute.For <IToolLocator>(); }
public VsMetricsRunnerFixture(bool defaultToolExist = true, PlatformFamily platform = PlatformFamily.Windows) : base("/Working/tools/metrics.exe") { InputFilePaths = new FilePath[] { "c:/tool.exe" }; OutputFilePath = "metrics_result.xml"; if (defaultToolExist) { FileSystem.CreateFile("/Working/tools/metrics.exe"); } Environment = new FakeEnvironment(platform); Environment.WorkingDirectory = "/Working"; }
void RunProtoc(string options, string absolutePath) { Logger.Normal($"where we are generating protobufs from {absolutePath}"); PlatformFamily platform = EnvironmentInfo.Platform; var protocEXELookup = new Dictionary <PlatformFamily, string>() { { PlatformFamily.OSX, "protoc_mac" }, { PlatformFamily.Linux, "protoc_linux" }, { PlatformFamily.Windows, "protoc.exe" } }; AbsolutePath protocLocation = RootDirectory / $"tools/protoc/{protocEXELookup[platform]}"; var protocTool = ToolResolver.GetLocalTool(protocLocation); protocTool.Invoke($"{options}", absolutePath); }
/// <summary> /// Initializes a new instance of the <see cref="FakeEnvironment"/> class. /// </summary> /// <param name="family">The platform family.</param> /// <param name="is64Bit">if set to <c>true</c>, the platform is 64 bit.</param> public FakeEnvironment(PlatformFamily family, bool is64Bit = true) { _environmentVariables = new Dictionary <string, string?>(StringComparer.OrdinalIgnoreCase); if (family == PlatformFamily.Windows) { WorkingDirectory = new DirectoryPath("C:/Working"); } else { WorkingDirectory = new DirectoryPath("/Working"); } Platform = new FakePlatform(family, is64Bit); }
public MSBuildRunnerFixture(bool is64BitOperativeSystem, PlatformFamily platformFamily) : base("MSBuild.exe") { // Create the list of all known MSBuild paths. KnownMSBuildPaths = new HashSet <FilePath>(new PathComparer(false)) { "/Windows/Microsoft.NET/Framework/v2.0.50727/MSBuild.exe", "/Windows/Microsoft.NET/Framework64/v2.0.50727/MSBuild.exe", "/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe", "/Windows/Microsoft.NET/Framework64/v3.5/MSBuild.exe", "/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe", "/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe", "/Program86/MSBuild/12.0/Bin/MSBuild.exe", "/Program86/MSBuild/12.0/Bin/amd64/MSBuild.exe", "/Program86/MSBuild/14.0/Bin/MSBuild.exe", "/Program86/MSBuild/14.0/Bin/amd64/MSBuild.exe", "/Program86/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe", "/Program86/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/amd64/MSBuild.exe", "/Program86/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe", "/Program86/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe", "/Program/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe", "/Program/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe", "/usr/bin/msbuild", "/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild" }; // Install all known MSBuild versions. foreach (var msBuildPath in KnownMSBuildPaths) { FileSystem.CreateFile(msBuildPath); } // Prepare the environment. Environment.SetSpecialPath(SpecialPath.ProgramFilesX86, "/Program86"); Environment.SetSpecialPath(SpecialPath.ProgramFiles, "/Program"); Environment.SetSpecialPath(SpecialPath.Windows, "/Windows"); Environment.ChangeOperativeSystemBitness(is64BitOperativeSystem); Environment.ChangeOperatingSystemFamily(platformFamily); if (platformFamily == PlatformFamily.Windows) { Environment.WorkingDirectory = new DirectoryPath("C:/Working"); Environment.ApplicationRoot = Environment.WorkingDirectory.Combine("bin"); } // Prepare the tool parameters. Solution = new FilePath("./src/Solution.sln"); Settings.ToolVersion = MSBuildToolVersion.VS2013; }
public PythonModuleAttribute(string /*!*/ name, Type /*!*/ type, PlatformFamily validPlatformFamily) { ContractUtils.RequiresNotNull(name, nameof(name)); ContractUtils.RequiresNotNull(type, nameof(type)); Name = name; Type = type; switch (validPlatformFamily) { case PlatformFamily.Unix: ValidPlatforms = Unix; break; default: ValidPlatforms = Windows; break; } }
static Platform() { #if WINDOWS_UWP IsUnix = false; IsWindows = true; #elif NET_STANDARD if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { PlatformType = PlatformType.Windows; PlatformFamily = PlatformFamily.Desktop; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { PlatformType = PlatformType.Linux; PlatformFamily = PlatformFamily.Desktop; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { PlatformType = PlatformType.MacOS; PlatformFamily = PlatformFamily.Desktop; } #else switch (Environment.OSVersion.Platform) { case PlatformID.Unix: PlatformType = PlatformType.Linux; PlatformFamily = PlatformFamily.Desktop; break; case PlatformID.MacOSX: PlatformType = PlatformType.MacOS; PlatformFamily = PlatformFamily.Desktop; break; default: PlatformType = PlatformType.Windows; PlatformFamily = PlatformFamily.Desktop; break; } #endif }
protected PlatformRestrictedTheoryAttribute( PlatformFamily requiredFamily, bool invert, string reason = null) { if ((requiredFamily != _family) ^ invert) { if (string.IsNullOrEmpty(reason)) { var platformName = Enum.GetName(typeof(PlatformFamily), requiredFamily); if (invert) { platformName = $"Non-{platformName}"; } reason = $"{platformName} test."; } Reason = reason; } }
public ToolResolverFixture(PlatformFamily family, bool is64Bit, Version frameworkVersion) { Environment = Substitute.For <ICakeEnvironment>(); Environment.Platform.Returns(info => { var platform = Substitute.For <ICakePlatform>(); platform.Is64Bit.Returns(is64Bit); platform.Family.Returns(family); return(platform); }); Environment.Runtime.Returns(info => { var runtime = Substitute.For <ICakeRuntime>(); runtime.BuiltFramework.Returns(callInfo => new FrameworkName(".Net 4.5.2", frameworkVersion)); return(runtime); }); FileSystem = Substitute.For <IFileSystem>(); ToolLocator = Substitute.For <IToolLocator>(); }
/// <summary> /// Initializes a new instance of the <see cref="FakePlatform"/> class. /// </summary> /// <param name="family">The family.</param> /// <param name="is64Bit">if set to <c>true</c>, the platform is 64-bit.</param> public FakePlatform(PlatformFamily family, bool is64Bit = true) { Family = family; Is64Bit = is64Bit; }
/// <summary> /// Initializes a new instance of the <see cref="CakePlatform"/> class. /// </summary> public CakePlatform() { _family = Machine.GetPlatformFamily(); _is64Bit = Machine.Is64BitOperativeSystem(); }
public TerraformPlanFixture(PlatformFamily platformFamily) : base(platformFamily) { }
protected TerraformFixture(PlatformFamily platformFamily = PlatformFamily.Windows) : base(platformFamily == PlatformFamily.Windows ? "terraform.exe" : "terraform") { Environment.Platform.Family = platformFamily; }
public TerraformDestroyFixture(PlatformFamily platformFamily) : base(platformFamily) { }
static WindowsFact() { Family = EnvironmentHelper.GetPlatformFamily(); }
public static bool IsLinux(PlatformFamily family) { return(family == PlatformFamily.Linux); }
public Fixture(PlatformFamily platformFamily = PlatformFamily.Windows) : base(platformFamily) { }
/// <summary> /// Change the operating system platform family. /// </summary> /// <param name="family">The platform family.</param> public void ChangeOperatingSystemFamily(PlatformFamily family) { Platform.Family = family; }
static WindowsFact() { _family = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PlatformFamily.Windows : PlatformFamily.Unknown; }
protected PulumiFixture(PlatformFamily platformFamily = PlatformFamily.Windows) : base(platformFamily == PlatformFamily.Windows ? "pulumi.exe" : "pulumi") { Environment.Platform.Family = platformFamily; }
public TFBuildProvider CreateTFBuildService(PlatformFamily platformFamily, DirectoryPath workingDirectory) { Environment.Platform.Family.Returns(platformFamily); Environment.WorkingDirectory.Returns(workingDirectory); return(CreateTFBuildService()); }
static WindowsTheory() { _family = EnvironmentHelper.GetPlatformFamily(); }
public static bool IsOSX(PlatformFamily family) { return(family == PlatformFamily.OSX); }
static OSXFact() { Family = EnvironmentHelper.GetPlatformFamily(); }
/// <summary> /// Determines whether the specified platform family is a Unix platform. /// </summary> /// <param name="family">The platform family.</param> /// <returns><c>true</c> if the platform is a Unix platform; otherwise <c>false</c>.</returns> public static bool IsUnix(PlatformFamily family) { return(family == PlatformFamily.Linux || family == PlatformFamily.MacOs); }
public AzurePipelinesProvider CreateAzurePipelinesService(PlatformFamily platformFamily, DirectoryPath workingDirectory) { Environment.Platform.Family.Returns(platformFamily); Environment.WorkingDirectory.Returns(workingDirectory); return(CreateAzurePipelinesService()); }