コード例 #1
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void ReadOnlyErrorOnNodeRename()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);
            conf.SetReadOnly(true);
            conf.Root.Name = "changed-name";
        }
コード例 #2
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void ReadOnlyErrorOnNodeDelete()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);
            conf.SetReadOnly(true);
            conf.Root["A"].Delete();
        }
コード例 #3
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void NodeCreate()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);

            Assert.AreEqual("A", conf.Root["A"].Name);
        }
コード例 #4
0
        public void NodeRename()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);
            conf.Root["A"].Name = "B";
            Aver.AreEqual("B", conf.Root["B"].Name);
        }
コード例 #5
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void RootDelete()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);

            Assert.AreEqual(true, conf.Root.Exists);
            conf.Root.Delete();
            Assert.AreEqual(false, conf.Root.Exists);
        }
コード例 #6
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void NodeDelete()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null);
            conf.Root.AddChildNode("B", null).AddChildNode("B1");
            conf.Root["A"].Delete();
            Assert.AreEqual(false, conf.Root["A"].Exists);
            Assert.AreEqual(true, conf.Root["B"].Exists);

            conf.Root.ResetModified();
            Assert.AreEqual(false, conf.Root["B"].Modified);
            conf.Root["B"]["B1"].Delete();
            Assert.AreEqual(true, conf.Root["B"].Modified);
        }
コード例 #7
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void NavigationAndValueAccessors()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", 10).AddChildNode("A.A", 20);
            conf.Root.AddChildNode("B", 789);
            conf.Root.AddChildNode("URI", UriKind.RelativeOrAbsolute);

            conf.Root["A"]["A.A"].AddChildNode("MARS", -1000);
            Assert.AreEqual(-1000, conf.Root["A"]["A.A"]["MARS"].ValueAsInt());
            Assert.AreEqual(-1000, conf.Root[0][0][0].ValueAsInt());
            Assert.AreEqual(789, conf.Root[1].ValueAsInt());
            Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["URI"].ValueAsEnum <UriKind>());
            Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["URI"].ValueAsEnum <UriKind>(UriKind.Absolute));
            Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["NONENTITY"].ValueAsEnum <UriKind>(UriKind.RelativeOrAbsolute));
        }
コード例 #8
0
        public void EmptySectionAndAttributeNodes()
        {
            var conf = new NFX.Environment.JSONConfiguration();
               conf.Create();
               conf.Root.AddChildNode("A", null).AddChildNode("A.A", "haha!").AddAttributeNode("good", true);

               Assert.AreEqual("haha!", conf.Root["A"]["A.A"].Value);
               Assert.AreEqual(true, conf.Root["A"]["A.A"].Exists);
               Assert.AreEqual(true, conf.Root["A"]["A.A"].AttrByName("good").Exists);
               Assert.AreEqual(true, conf.Root["A"]["A.A"].AttrByIndex(0).Exists);

               Assert.AreEqual(false, conf.Root["A1"]["A.A"].Exists);
               Assert.AreEqual(false, conf.Root["A"]["A.A1"].Exists);

               Assert.AreEqual(false, conf.Root["A"]["A.A"].AttrByName("bad").Exists);
               Assert.AreEqual(false, conf.Root["A"]["A.A"].AttrByIndex(100).Exists);
        }
コード例 #9
0
ファイル: JSONConfigurationTest.cs プロジェクト: filmor/nfx
        public void EmptySectionAndAttributeNodes()
        {
            var conf = new NFX.Environment.JSONConfiguration();

            conf.Create();
            conf.Root.AddChildNode("A", null).AddChildNode("A.A", "haha!").AddAttributeNode("good", true);

            Assert.AreEqual("haha!", conf.Root["A"]["A.A"].Value);
            Assert.AreEqual(true, conf.Root["A"]["A.A"].Exists);
            Assert.AreEqual(true, conf.Root["A"]["A.A"].AttrByName("good").Exists);
            Assert.AreEqual(true, conf.Root["A"]["A.A"].AttrByIndex(0).Exists);

            Assert.AreEqual(false, conf.Root["A1"]["A.A"].Exists);
            Assert.AreEqual(false, conf.Root["A"]["A.A1"].Exists);

            Assert.AreEqual(false, conf.Root["A"]["A.A"].AttrByName("bad").Exists);
            Assert.AreEqual(false, conf.Root["A"]["A.A"].AttrByIndex(100).Exists);
        }
コード例 #10
0
        public void RootDelete()
        {
            var conf = new NFX.Environment.JSONConfiguration();
               conf.Create();
               conf.Root.AddChildNode("A", null);

               Assert.AreEqual(true, conf.Root.Exists);
               conf.Root.Delete();
               Assert.AreEqual(false, conf.Root.Exists);
        }
コード例 #11
0
 public void ReadOnlyErrorOnNodeRename()
 {
     var conf = new NFX.Environment.JSONConfiguration();
        conf.Create();
        conf.Root.AddChildNode("A", null);
        conf.SetReadOnly(true);
        conf.Root.Name = "changed-name";
 }
コード例 #12
0
 public void ReadOnlyErrorOnNodeDelete()
 {
     var conf = new NFX.Environment.JSONConfiguration();
        conf.Create();
        conf.Root.AddChildNode("A", null);
        conf.SetReadOnly(true);
        conf.Root["A"].Delete();
 }
コード例 #13
0
 public void NodeRename()
 {
     var conf = new NFX.Environment.JSONConfiguration();
        conf.Create();
        conf.Root.AddChildNode("A", null);
        conf.Root["A"].Name = "B";
        Assert.AreEqual("B", conf.Root["B"].Name);
 }
コード例 #14
0
        public void NodeDelete()
        {
            var conf = new NFX.Environment.JSONConfiguration();
               conf.Create();
               conf.Root.AddChildNode("A", null);
               conf.Root.AddChildNode("B", null).AddChildNode("B1");
               conf.Root["A"].Delete();
               Assert.AreEqual(false, conf.Root["A"].Exists);
               Assert.AreEqual(true, conf.Root["B"].Exists);

               conf.Root.ResetModified();
               Assert.AreEqual(false, conf.Root["B"].Modified);
               conf.Root["B"]["B1"].Delete();
               Assert.AreEqual(true, conf.Root["B"].Modified);
        }
コード例 #15
0
        public void NavigationAndValueAccessors()
        {
            var conf = new NFX.Environment.JSONConfiguration();
               conf.Create();
               conf.Root.AddChildNode("A", 10).AddChildNode("A.A", 20);
               conf.Root.AddChildNode("B", 789);
               conf.Root.AddChildNode("URI", UriKind.RelativeOrAbsolute);

               conf.Root["A"]["A.A"].AddChildNode("MARS", -1000);
               Assert.AreEqual(-1000, conf.Root["A"]["A.A"]["MARS"].ValueAsInt());
               Assert.AreEqual(-1000, conf.Root[0][0][0].ValueAsInt());
               Assert.AreEqual(789, conf.Root[1].ValueAsInt());
               Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["URI"].ValueAsEnum<UriKind>());
               Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["URI"].ValueAsEnum<UriKind>(UriKind.Absolute));
               Assert.AreEqual(UriKind.RelativeOrAbsolute, conf.Root["NONENTITY"].ValueAsEnum<UriKind>(UriKind.RelativeOrAbsolute));
        }