예제 #1
0
        public void ConfigAttributeApplyToICongifSectionPropertyAndField()
        {
          var conf = NFX.Environment.XMLConfiguration.CreateFromXML(xml);

          var cl = new MyClass();
          ConfigAttribute.Apply(cl, conf.Root);

         
           Assert.AreEqual("YES!", cl.OptionsProp["hello"].Value);
           Assert.AreEqual(1, cl.OptionsProp["hello"].AttrByName("a").ValueAsInt());

           Assert.AreEqual("YES!", cl.OptionsField["hello"].Value);
           Assert.AreEqual(1, cl.OptionsField["hello"].AttrByName("a").ValueAsInt());
        }
예제 #2
0
        public void ConfigAttributeWithoutPath()
        {
          var conf = NFX.Environment.XMLConfiguration.CreateFromXML(xml);

          var cl = new MyClass();
          ConfigAttribute.Apply(cl, conf.Root);

          Assert.AreEqual(99, cl.Age);
          Assert.AreEqual(890, cl.Age2);
          Assert.AreEqual(1890, cl.TheNewAge);
        }
예제 #3
0
        public void ConfigAttributeByteArray()
        {
          var conf = NFX.Environment.XMLConfiguration.CreateFromXML(xml);

          var cl = new MyClass();
          ConfigAttribute.Apply(cl, conf.Root);

          var bytes =  cl.Bytes;
          Assert.AreEqual(16, bytes.Length);

          Assert.AreEqual(0, bytes[00]);
          Assert.AreEqual(1, bytes[01]);
          Assert.AreEqual(2, bytes[02]);
          Assert.AreEqual(3, bytes[03]);
          Assert.AreEqual(4, bytes[04]);
          Assert.AreEqual(5, bytes[05]);
          Assert.AreEqual(6, bytes[06]);
          Assert.AreEqual(7, bytes[07]);
          Assert.AreEqual(8, bytes[08]);
          Assert.AreEqual(9, bytes[09]);
          Assert.AreEqual(0xa, bytes[10]);
          Assert.AreEqual(0xb, bytes[11]);
          Assert.AreEqual(0xc, bytes[12]);
          Assert.AreEqual(0xd, bytes[13]);
          Assert.AreEqual(0xe, bytes[14]);
          Assert.AreEqual(0xf, bytes[15]);
        }
예제 #4
0
        public void ConfigAttributeApply()
        {
          var conf = NFX.Environment.XMLConfiguration.CreateFromXML(xml);

          var cl = new MyClass();
          ConfigAttribute.Apply(cl, conf.Root);

          Assert.AreEqual("private", cl.getPrivateName());
          Assert.AreEqual("protected", cl.getProtectedName());
          Assert.AreEqual("public", cl.m_PublicName);


           Assert.AreEqual(-892, cl.getPrivateInt());
           Assert.AreEqual(23567, cl.getPrivateProperty());

          Assert.AreEqual("xxx", cl.Format);

          Assert.AreEqual(99, cl.Age);
          Assert.AreEqual(MyEnum.B, cl.MyEnumField);

          Assert.AreEqual(5, cl.When.Month);
          Assert.AreEqual(12, cl.When.Day);
          Assert.AreEqual(1982, cl.When.Year);

          Assert.AreEqual(true, cl.Fuzzy.Value);

          Assert.AreEqual(false, cl.Jazzy.HasValue);

           Assert.AreEqual(155, cl.NoneInt);
           Assert.AreEqual(true, cl.NoneBool);
           Assert.AreEqual("This is default", cl.NoneString);
        }