示例#1
0
        public void Test1()
        {
            var c1 = new Cls1 {
                Name = "c1", Cls2 = new Cls2 {
                    Name = "c2"
                }
            };

            c1.Cls2.Cls3List.Add(new Cls3 {
                Name = "c31"
            });
            c1.Cls2.Cls3List.Add(new Cls3 {
                Name = "c32"
            });
            var c4 = new Cls4 {
                Name = "c4"
            };

            c4.Cls3List.Add(c1.Cls2.Cls3List[0]);
            var c5 = new Cls5 {
                Name = "c5", Cls4 = c1.Cls2.Cls3List[0].Cls4
            };

            c1.Save();

            var c = Cls1.FindById(c1.Id);

            Assert.AreEqual("c1", c.Name);
            Assert.AreEqual("c2", c.Cls2.Name);
            Assert.AreEqual(2, c.Cls2.Cls3List.Count);
            Assert.AreEqual("c31", c.Cls2.Cls3List[0].Name);
            Assert.AreEqual("c32", c.Cls2.Cls3List[1].Name);
            Assert.AreEqual("c4", c.Cls2.Cls3List[0].Cls4.Name);
            Assert.AreEqual("c5", c.Cls2.Cls3List[0].Cls4.Cls5.Name);
        }
示例#2
0
        public void Test4()
        {
            var c1 = new Cls1 {
                Name = "c1"
            };

            c1.Cls2.Value = new Cls2 {
                Name = "c2"
            };
            c1.Cls2.Value.Cls3List.Add(new Cls3 {
                Name = "c31"
            });
            c1.Cls2.Value.Cls3List.Add(new Cls3 {
                Name = "c32"
            });
            var cl4 = new Cls4 {
                Name = "c4"
            };

            cl4.Cls5.Value = new Cls5 {
                Name = "c5"
            };
            c1.Cls2.Value.Cls3List[0].Cls4.Value = cl4;

            c1.Save();

            var c4 = Cls4.FindById(c1.Cls2.Value.Cls3List[0].Cls4.Value.Id);

            c4.Cls5.Value = new Cls5 {
                Name = "c5x"
            };

            c4.Save();

            var c = Cls1.FindById(c1.Id);

            Assert.AreEqual("c1", c.Name);
            Assert.AreEqual("c2", c.Cls2.Value.Name);
            Assert.AreEqual(2, c.Cls2.Value.Cls3List.Count);
            Assert.AreEqual("c31", c.Cls2.Value.Cls3List[0].Name);
            Assert.AreEqual("c32", c.Cls2.Value.Cls3List[1].Name);
            Assert.AreEqual("c4", c.Cls2.Value.Cls3List[0].Cls4.Value.Name);
            Assert.AreEqual("c5x", c.Cls2.Value.Cls3List[0].Cls4.Value.Cls5.Value.Name);
        }