예제 #1
0
        public void YamlTest()
        {
            var ys = new SerializerBuilder().Build();
            var s  = ys.Serialize(new { Field1 = "one", Field2 = "two", });

            Console.WriteLine(s);
            Assert.AreEqual($"Field1: one{Environment.NewLine}Field2: two{Environment.NewLine}", s);
            var x = new { Name = "None", Count = 4, };

            s = ys.Serialize(new { Field1 = "one", Field2 = "two", Az1 = x, Az2 = x, });
            Console.WriteLine(s);
            Assert.AreEqual($"Field1: one{Environment.NewLine}Field2: two{Environment.NewLine}Az1: &o0{Environment.NewLine}  Name: None{Environment.NewLine}  Count: 4{Environment.NewLine}Az2: *o0{Environment.NewLine}", s);

            var site = new IvrSiteSchema {
                HostedZoneDomain = "my.site.domain.net",
                SipProviders     = new List <string> {
                    "Twilio",
                },
                IngressPorts = new List <PortSpec> {
                    PortSpec.Parse("SIP 5060"), PortSpec.Parse("RTP 5064-6000"),
                },
                RdpProps = new RdpProps {
                    UserName = "******",
                    Password = "******",
                    Cidrs    = new List <string> {
                        "1.2.3.4/32",
                    }
                },
                HostGroups = new List <HostGroup> {
                    new HostGroup {
                        AllocateNewElasticIPs = true,
                        HostCount             = 2,
                        InstallS3i            = "https://raw.githubusercontent.com/OlegBoulanov/s3i/develop/Examples/Config.ini",
                    },
                    new HostGroup {
                        AllocateNewElasticIPs = false,
                        HostCount             = 16,
                        InstallS3i            = "https://raw.githubusercontent.com/OlegBoulanov/s3i/develop/Examples/Config.ini",
                    },
                },
            };

            s = ys.Serialize(site);
            Console.WriteLine(s);
            var yd    = new YamlDotNet.Serialization.DeserializerBuilder().Build();
            var site2 = yd.Deserialize <IvrSiteSchema>(s);

            Assert.AreEqual(2, site2.HostGroups.Count());

/*
 *          Console.WriteLine("******");
 *          using(var sr = new StreamReader($"{OSAgnostic.Home}/Projects/CdkTest-1.yaml")) {
 *              var site1 = yd.Deserialize<IvrSiteSchema>(sr.ReadToEnd());
 *              Console.WriteLine(ys.Serialize(site1));
 *          }
 */
        }
예제 #2
0
 public void Parse()
 {
     ParseAndCheck("SIP 5060");
     ParseAndCheck("SIPS 5060-5061");
     ParseAndCheck("RTP 5062-5600");
     //PortRangeSpec.Parse("XYZ:");
     Assert.Throws(typeof(FormatException), () => { PortSpec.Parse("XYZ"); });
     Assert.Throws(typeof(FormatException), () => { PortSpec.Parse("X Y Z"); });
     Assert.Throws(typeof(FormatException), () => { PortSpec.Parse("X Y-Z-W"); });
     Assert.Throws(typeof(FormatException), () => { PortSpec.Parse("XYZ "); });
 }
예제 #3
0
 void ParseAndCheck(string s)
 {
     Assert.AreEqual(s, PortSpec.Parse(s).ToString());
 }