public void UpsEnvParser_2()
        {
            var upsFolder = Helpers.TestHelper.UPS_Folder();

            var vcap = File.ReadAllText("vcap.json");

            Environment.SetEnvironmentVariable(UpsEnvParser.ENV_VAR, vcap);

            var upsParser = new UpsEnvParser(upsFolder);

            Assert.Equal(2, upsParser.UpsCount);

            Assert.False(upsParser.IsLocal);

            var names = upsParser.UpsNames;

            foreach (var k in names)
            {
                this.output.WriteLine("{0}", k);
            }

            var upsName = names[0];

            Assert.True(upsParser.UpsExists(upsName));

            var key           = "name";
            var valueExpected = "Service01";

            Assert.True(upsParser.UpsKeyExists(upsName, key));

            var value = upsParser.UpsKeyGetValue(upsName, key);

            Assert.Equal(valueExpected, value);

            var keys = upsParser.UpsKeys(upsName);

            foreach (var k in keys)
            {
                this.output.WriteLine("{0}", k);
            }

            var d = upsParser.UpsKeyValues(upsName);

            foreach (var item in d)
            {
                this.output.WriteLine("{0}: {1}", item.Key, item.Value);
            }

            var fakeKey = "FakeKey";

            value = upsParser.UpsKeyGetValue(upsName, fakeKey);

            Assert.True(string.IsNullOrWhiteSpace(value));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var localPath = @".\UPS\";
            var upsParser = new UpsEnvParser(localPath);

            Assert.Equal(2, upsParser.UpsCount);

            Assert.True("IsLocal", upsParser.IsLocal);

            var names = upsParser.UpsNames;

            foreach (var k in names)
            {
                System.Console.WriteLine("{0}", k);
            }

            var upsName = names[0];

            Assert.True("UpsExists: " + upsName, upsParser.UpsExists(upsName));

            var key           = "name";
            var valueExpected = "Service01";

            Assert.True(string.Format("Exists: {0}->{1}", upsName, key), upsParser.UpsKeyExists(upsName, key));

            var value = upsParser.UpsKeyGetValue(upsName, key);

            Assert.Equal(valueExpected, value);

            var fakeKey = "FakeKey";

            value = upsParser.UpsKeyGetValue(upsName, fakeKey);

            Assert.True("Empty", string.IsNullOrWhiteSpace(value));

            Environment.ExitCode = 0;

            System.Console.WriteLine("Please `cf stop PcfDotNetCoreConsole`!");

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
            }
        }
        public void UpsEnvParser_1()
        {
            var upsFolder = Helpers.TestHelper.UPS_Folder();

            var upsParser = new UpsEnvParser(upsFolder);

            Assert.Equal(2, upsParser.UpsCount);

            Assert.True(upsParser.IsLocal);

            var names = upsParser.UpsNames;

            foreach (var k in names)
            {
                this.output.WriteLine("{0}", k);
            }

            var upsName = names[0];

            Assert.True(upsParser.UpsExists(upsName));

            var key           = "name";
            var valueExpected = "Service01";

            Assert.True(upsParser.UpsKeyExists(upsName, key));

            var value = upsParser.UpsKeyGetValue(upsName, key);

            Assert.Equal(valueExpected, value);

            var fakeKey = "FakeKey";

            value = upsParser.UpsKeyGetValue(upsName, fakeKey);

            Assert.True(string.IsNullOrWhiteSpace(value));
        }