public void OnNotExistingFile_DoNothing()
        {
            _fileSystem.TryReadAllTextFromFile(Arg.Any <string>()).Returns(a => null);

            var reader = new EnvironmentVariablesFileReader(_fileSystem, enviroment);

            reader.ReadFromFile();

            enviroment.DidNotReceiveWithAnyArgs().WhenForAnyArgs(a => a.SetEnvironmentVariableForProcess(Arg.Any <string>(), Arg.Any <string>()));
        }
        public void ReadsEnvFromDefaultFile()
        {
            var envFilePath = enviroment.PlatformSpecificPathPrefix + "/gigya/environmentVariables.json";

            var reader = new EnvironmentVariablesFileReader(_fileSystem, enviroment);

            reader.ReadFromFile();


            _fileSystem.Received().TryReadAllTextFromFile(envFilePath);
        }
        public void ReadAndSeEnvVariables_AllEmpty()
        {
            envVariables = new Dictionary <string, string>();

            var reader = new EnvironmentVariablesFileReader(_fileSystem, enviroment);

            reader.ReadFromFile();

            enviroment.GetEnvironmentVariable("DC").ShouldBe("il11");
            enviroment.GetEnvironmentVariable("ENV").ShouldBe("orl11");
            enviroment.GetEnvironmentVariable("GIGYA_CONFIG_PATHS_FILE").ShouldBe("C:\\gigya\\Config\\loadPaths1.json");
        }
        public void OnFileParsingFailure_DoNothing()
        {
            _fileSystem.TryReadAllTextFromFile(Arg.Any <string>()).Returns(a => @"Invalid JSON file");

            Action doAction = () =>
            {
                var reader = new EnvironmentVariablesFileReader(_fileSystem, enviroment);
                reader.ReadFromFile();
            };

            doAction.ShouldThrow <ConfigurationException>();
            enviroment.DidNotReceiveWithAnyArgs().WhenForAnyArgs(a => a.SetEnvironmentVariableForProcess(Arg.Any <string>(), Arg.Any <string>()));
        }
        public void ReadsEnvFromDifferentFile()
        {
            envVariables = new Dictionary <string, string> {
                { "GIGYA_ENVVARS_FILE", "C:\\gigya\\envVars.json" }
            };


            var reader = new EnvironmentVariablesFileReader(_fileSystem, enviroment);

            reader.ReadFromFile();


            _fileSystem.Received().TryReadAllTextFromFile("C:\\gigya\\envVars.json");
        }