Ejemplo n.º 1
0
        public void Case09_complex_list()
        {
            var d1 = new BBDoc
            {
                B          = 900,
                BB         = -800.123,
                Name       = "Moon",
                ListOthers = new List <BaseDoc> {
                    new ADoc {
                        Name = "A0", A = 0
                    },
                    null,
                    new BDoc {
                        Name = "B2", B = 2
                    },
                    new BBDoc {
                        Name = "BB3", B = 3
                    },
                    new AADoc {
                        Name = "AA4", A = 4
                    }
                }
            };

            var json = d1.ToJson();

            json.See();

            var got = JsonReader.ToDoc <BaseDoc>(json);//BB deser to BaseDoc

            Aver.IsNotNull(got);
            Aver.IsTrue(got is BBDoc);
            Aver.AreEqual("Moon", got.Name);
            Aver.AreEqual(900, ((BBDoc)got).B);
            Aver.AreEqual(-800.123, ((BBDoc)got).BB);
            Aver.IsNotNull(got.ListOthers);
            Aver.AreEqual(5, got.ListOthers.Count);

            Aver.IsTrue(got.ListOthers[0] is ADoc);
            Aver.IsNull(got.ListOthers[1]);
            Aver.IsTrue(got.ListOthers[2] is BDoc);
            Aver.IsTrue(got.ListOthers[3] is BBDoc);
            Aver.IsTrue(got.ListOthers[4] is AADoc);

            Aver.AreEqual("A0", got.ListOthers[0].Name);
            Aver.AreEqual("B2", got.ListOthers[2].Name);
            Aver.AreEqual("BB3", got.ListOthers[3].Name);
            Aver.AreEqual("AA4", got.ListOthers[4].Name);

            Aver.AreEqual(0, ((ADoc)got.ListOthers[0]).A);
            Aver.AreEqual(2, ((BDoc)got.ListOthers[2]).B);
            Aver.AreEqual(3, ((BBDoc)got.ListOthers[3]).B);
            Aver.AreEqual(4, ((AADoc)got.ListOthers[4]).A);

            got.See();
        }
Ejemplo n.º 2
0
        public void Case10_logical_diff_withcollections_1_rank()
        {
            var d1 = new BBDoc
            {
                B          = 900,
                BB         = -800.123,
                Name       = "Saturn",
                ListOthers = new List <BaseDoc> {
                    new ADoc {
                        Name = "A0", A = 0
                    },
                    null,
                    new BDoc {
                        Name = "B2", B = 2
                    },
                    new BBDoc {
                        Name = "BB3", B = 3
                    },
                    null,
                    null,
                    new AADoc {
                        Name = "AA4", A = 4
                    }
                },
                ArrayOthers = new BaseDoc[] {
                    new AADoc {
                        Name = "A0", A = -9, AA = 12343.0123
                    },
                    null,
                    null,
                    new BDoc {
                        Name = "B2", B = 2
                    }
                }
            };

            var json = d1.ToJson();

            json.See();

            var got = JsonReader.ToDoc <BaseDoc>(json);//BB deser to BaseDoc

            var cmp = new DocLogicalComparer {
                LoopByA = true, LoopByB = true, LoopByAmorphous = false
            };
            var result = cmp.Compare(d1, got);

            Aver.IsTrue(result.AreSame);
        }
Ejemplo n.º 3
0
        public void Case10_logical_diff_basic()
        {
            var d1 = new BBDoc
            {
                B    = 900,
                BB   = -800.123,
                Name = "Moon"
            };

            var json = d1.ToJson();

            json.See();

            var got = JsonReader.ToDoc <BaseDoc>(json);//BB deser to BaseDoc

            var cmp = new DocLogicalComparer {
                LoopByA = true, LoopByB = true, LoopByAmorphous = false
            };
            var result = cmp.Compare(d1, got);

            Aver.IsTrue(result.AreSame);
        }
Ejemplo n.º 4
0
        public void Case11_logical_diff_withcollections_2_rank()
        {
            var d1 = new BBDoc
            {
                B          = 900,
                BB         = -800.123,
                Name       = "Saturn",
                ListOthers = new List <BaseDoc> {
                    new ADoc {
                        Name = "A0", A = 0, ArrayOthers = new BaseDoc[] { new ADoc {
                                                                              Name = "Elm1"
                                                                          }, null, null, new BDoc {
                                                                              Name = "Elm2"
                                                                          } }
                    },
                    null,
                    new BDoc {
                        Name = "B2", B = 2, ListOthers = new List <BaseDoc> {
                        }
                    },                                                    //empty list
                    new BBDoc {
                        Name = "BB3", B = 3
                    },
                    null,
                    new AADoc {
                        Name        = "AA4", A = 4,
                        ArrayOthers = new BaseDoc[] { new ADoc {
                                                          Name = "Elm1"
                                                      }, new BDoc {
                                                          Name = "Elm2"
                                                      } },
                        ListOthers = new List <BaseDoc> {
                            new BBDoc {
                                Name = "updown", BB = 345.1
                            }, new BDoc {
                                Name = "cu-cu", B = -546
                            }
                        }
                    },
                    null
                },
                ArrayOthers = new BaseDoc[] {
                    new AADoc {
                        Name = "A0", A = -9, AA = 12343.0123
                    },
                    null,
                    null,
                    new BDoc {
                        Name = "B2", B = 2, ListOthers = new List <BaseDoc> {
                            new ADoc {
                                Name = "23", A = 23
                            },
                            new ADoc {
                                Name = "24", A = 24
                            },
                            new BDoc {
                                Name       = "25", B = 25,
                                ListOthers = new List <BaseDoc> {
                                    new BBDoc {
                                        Name = "town-down", BB = -1000
                                    }
                                }
                            },
                        }
                    }
                }
            };

            var json = d1.ToJson();

            json.See();

            var got = JsonReader.ToDoc <BaseDoc>(json);//BB deser to BaseDoc


            got.See();

            var cmp = new DocLogicalComparer {
                LoopByA = true, LoopByB = true, LoopByAmorphous = false
            };
            var result = cmp.Compare(d1, got);

            Aver.IsTrue(result.AreSame);
        }