public void TryGetValuesFromConfigFileTest()
        {
            Dictionary <string, string> parsedValues = new Dictionary <string, string>();
            EnvironmentVariables        variable;

            string ConfigPath = TestUtility.TestDirectory + "\\MyClusterConfig.json";

            parsedValues = new Dictionary <string, string>()
            {
                { ParameterNames.ClusterConfigFilePath, ConfigPath },
            };
            variable = EnvironmentVariables.CreateFromProgramParameters(parsedValues);
            Assert.AreEqual(ConfigPath, variable.ClusterConfigFilePath);
            Assert.IsNull(variable.FabricDataRoot);
            Assert.IsNull(variable.FabricLogRoot);
            Assert.IsNull(variable.Nodes);

            // returns false because data root path doesn't exist in the test
            Assert.IsFalse(variable.TryGetValuesFromConfigFile());
            Assert.AreEqual("D:\\ProgramData\\CustomDataRoot", variable.FabricDataRoot);
            Assert.AreEqual("D:\\ProgramData\\CustomLogRoot", variable.FabricLogRoot);
            Assert.IsNotNull(variable.Nodes);

            string nodeName = "vm";
            string nodeIp   = "Machine";
            int    index    = 0;

            foreach (var node in variable.Nodes)
            {
                Assert.AreEqual(node.Item1, nodeName + index);
                Assert.AreEqual(node.Item2, nodeIp + index);
                index++;
            }

            TestUtility.TestEpilog();
        }
        public void CreateFromProgramParametersTest()
        {
            Dictionary <string, string> parsedValues = new Dictionary <string, string>();
            EnvironmentVariables        variable;

            variable = EnvironmentVariables.CreateFromProgramParameters(parsedValues);
            Assert.IsFalse(string.IsNullOrWhiteSpace(variable.OutputDirectoryPath));
            Assert.IsTrue(variable.StartUtcTime < variable.EndUtcTime);
            Assert.IsTrue(variable.StartUtcTime > variable.EndUtcTime - TimeSpan.FromHours(2));
            Assert.IsTrue(variable.EndUtcTime < DateTime.UtcNow + TimeSpan.FromHours(1));
            Assert.IsFalse(variable.IncludeLeaseLogs);
            Assert.IsFalse(variable.IncludeCrashDumps);
            Assert.AreEqual(Scopes.Cluster, variable.Scope);
            Assert.AreEqual(false, variable.AcceptEula);
            Assert.AreEqual(Modes.CollectAndUpload, variable.Mode);
            TestUtility.TestEpilog();

            string   expectedOutput  = "c:\\hiahia.zip";
            DateTime expectedEndTime = new DateTime(2, 2, 2);

            parsedValues = new Dictionary <string, string>()
            {
                { ParameterNames.Output, expectedOutput },
                { ParameterNames.EndUtcTime, expectedEndTime.ToString() },
                { ParameterNames.Scope, "Cluster" },
            };
            variable = EnvironmentVariables.CreateFromProgramParameters(parsedValues);
            Assert.AreEqual(expectedOutput, variable.OutputDirectoryPath);
            Assert.IsTrue(variable.StartUtcTime < variable.EndUtcTime);
            Assert.IsTrue(variable.StartUtcTime > variable.EndUtcTime - TimeSpan.FromHours(2));
            Assert.AreEqual(expectedEndTime.ToUniversalTime(), variable.EndUtcTime);
            Assert.IsFalse(variable.IncludeLeaseLogs);
            Assert.IsFalse(variable.IncludeCrashDumps);
            Assert.AreEqual(Scopes.Cluster, variable.Scope);
            Assert.AreEqual(false, variable.AcceptEula);
            Assert.AreEqual(Modes.CollectAndUpload, variable.Mode);
            Assert.IsNull(variable.FabricDataRoot);
            TestUtility.TestEpilog();

            DateTime expectedStartTime = new DateTime(1, 1, 1);

            parsedValues = new Dictionary <string, string>()
            {
                { ParameterNames.StartUtcTime, expectedStartTime.ToString() },
                { ParameterNames.IncludeLeaseLogs, "true" },
                { ParameterNames.Scope, Scopes.Node.ToString() },
                { ParameterNames.AcceptEula, "true" },
                { ParameterNames.Mode, "collectandupload" },
                { ParameterNames.ClusterConfigFilePath, "c:\\SFPackage\\ClusterConfig.json" },
                { ParameterNames.IncludeCrashDumps, "true" },
            };
            variable = EnvironmentVariables.CreateFromProgramParameters(parsedValues);
            Assert.IsFalse(string.IsNullOrWhiteSpace(variable.OutputDirectoryPath));
            Assert.IsTrue(variable.StartUtcTime < variable.EndUtcTime);
            Assert.IsTrue(variable.StartUtcTime > DateTime.UtcNow - TimeSpan.FromHours(2));
            Assert.IsTrue(variable.EndUtcTime < DateTime.UtcNow + TimeSpan.FromHours(1));
            Assert.IsTrue(variable.IncludeLeaseLogs);
            Assert.IsTrue(variable.IncludeCrashDumps);
            Assert.AreEqual(Scopes.Node, variable.Scope);
            Assert.AreEqual(true, variable.AcceptEula);
            Assert.AreEqual(Modes.CollectAndUpload, variable.Mode);
            Assert.AreEqual("c:\\SFPackage\\ClusterConfig.json", variable.ClusterConfigFilePath);
            TestUtility.TestEpilog();
        }