public void AppVeyor_BuildVersion_Read(bool isMaster)
        {
            _arguments.HasArgument(VersionHelper.DefaultBuildVersionArgumentName).Returns(false);
            _appVeyor.IsRunningOnAppVeyor.Returns(true);
            _environment.SetEnvironmentVariable("APPVEYOR_BUILD_VERSION", "2.3.4");
            var versionHelper = GetVersionHelper(isMaster ? VersionHelper.DefaultDefaultBranchName : "someFeature");

            Assert.That(versionHelper.IsAppVeyor, Is.EqualTo(true));
            Assert.That(versionHelper.GetBaseVersionString(FallBackVersion), Is.EqualTo("2.3.4"));
        }
        public void Can_Get_Environment_Variable_As_Bool(string name, string value, bool?defaultValue, bool?expectedValue)
        {
            var cakeEnvironment = new FakeEnvironment(PlatformFamily.Windows, is64Bit: true);

            cakeEnvironment.SetEnvironmentVariable(name, value);

            var environmentProvider = (IEnvironmentProvider) new EnvironmentProvider(cakeEnvironment);
            var actualValue         = environmentProvider.GetEnvironmentVariableAsBool(name, defaultValue);

            actualValue.Should().Be(expectedValue);
        }
        public void Can_Get_Environment_Variable_As_String_With_Overrides(string name, string value, string defaultValue, string expectedValue)
        {
            var cakeEnvironment = new FakeEnvironment(PlatformFamily.Windows, is64Bit: true);

            cakeEnvironment.SetEnvironmentVariable(name, "SOMEVALUE");

            var environmentProvider = (IEnvironmentProvider) new EnvironmentProvider(cakeEnvironment);
            var overrides           = new Dictionary <string, string> {
                { name, value }
            };

            environmentProvider.SetOverrides(overrides);

            var actualValue = environmentProvider.GetEnvironmentVariable(name, defaultValue);

            actualValue.Should().Be(expectedValue);
        }
Exemplo n.º 4
0
 internal static FakeEnvironment AddEnvironmentVariable(this FakeEnvironment environment, string variable, string value)
 {
     environment.SetEnvironmentVariable(variable, value);
     return(environment);
 }