Exemplo n.º 1
0
        public void ReadAndSeEnvVariables_AllEmpty()
        {
            var environmentVariableProvider = new EnvironmentVariableProvider(_fileSystem, new CurrentApplicationInfo("test"));

            environmentVariableProvider.GetEnvironmentVariable("ZONE").ShouldBe("il1a");
            environmentVariableProvider.GetEnvironmentVariable("REGION").ShouldBe("il1");
            environmentVariableProvider.GetEnvironmentVariable("ENV").ShouldBe("orl11");
            environmentVariableProvider.GetEnvironmentVariable("GIGYA_CONFIG_PATHS_FILE").ShouldBe("c:\\gigya\\config\\loadpaths1.json");
        }
Exemplo n.º 2
0
        public void OnNotExistingFile_DoNothing()
        {
            _fileSystem.TryReadAllTextFromFile(Arg.Any <string>()).Returns(a => null);

            var environmentVariableProvider = new EnvironmentVariableProvider(_fileSystem, new CurrentApplicationInfo("test"));

            // assert environment variables were not changed
            environmentVariableProvider.GetEnvironmentVariable("ZONE").ShouldBe(DEFAULT_ZONE);
            environmentVariableProvider.GetEnvironmentVariable("REGION").ShouldBe(DEFAULT_REGION);
            environmentVariableProvider.GetEnvironmentVariable("ENV").ShouldBe(DEFAULT_ENV);
        }
        public void ReadAndSeEnvVariables_SomeEmpty()
        {
            Environment.SetEnvironmentVariable("ZONE", "il1b");

            var environmentVariableProvider = new EnvironmentVariableProvider(_fileSystem);

            environmentVariableProvider.GetEnvironmentVariable("ZONE").ShouldBe("il1a");
            environmentVariableProvider.GetEnvironmentVariable("REGION").ShouldBe("il1");
            environmentVariableProvider.GetEnvironmentVariable("ENV").ShouldBe("orl11");
            environmentVariableProvider.GetEnvironmentVariable("GIGYA_CONFIG_PATHS_FILE").ShouldBe("c:\\gigya\\config\\loadpaths1.json");
        }
        public static void GetEnvironmentVariableT_GivenMissingVariable_ReturnsDefaultValue()
        {
            var env        = new EnvironmentVariableProvider();
            var missingVar = env.GetEnvironmentVariable <int>("THIS_WILL_NOT_BE_FOUND");

            Assert.AreEqual(missingVar, default(int));
        }
        public static void GetEnvironmentVariable_GivenMissingVariable_ReturnsNull()
        {
            var env        = new EnvironmentVariableProvider();
            var missingVar = env.GetEnvironmentVariable("THIS_WILL_NOT_BE_FOUND");

            Assert.IsNull(missingVar);
        }
        public static void GetEnvironmentVariableT_GivenExistingVariableAndCorrectType_ReturnsCorrectValue()
        {
            var env = new EnvironmentVariableProvider();

            var numberOfProcessors = env.GetEnvironmentVariable <int>("NUMBER_OF_PROCESSORS");

            Assert.IsTrue(numberOfProcessors > 0);
        }
        public static void GetEnvironmentVariable_GivenExistingVariable_ReturnsCorrectValue()
        {
            var env = new EnvironmentVariableProvider();

            var providerPath = env.GetEnvironmentVariable("PATH");
            var sysPath      = Environment.GetEnvironmentVariable("PATH");

            Assert.AreEqual(sysPath, providerPath);
        }