Beispiel #1
0
        public void SerializeDeserialize_Empty_Test()
        {
            var tallyHistoryCollection = new TallyHistoryCollection(10);

            var xmlText = tallyHistoryCollection.Serialize();

            var deserializeResult = TallyHistoryCollection.Deserialize(xmlText);

            deserializeResult.Should().HaveSameCount(tallyHistoryCollection);

            foreach (var item in deserializeResult.Zip(tallyHistoryCollection, (x, y) => new { Left = x, Right = y }))
            {
                item.Left.TreeCN.Should().Be(item.Right.TreeCN);
                item.Left.TreeEstimateCN.Should().Be(item.Right.TreeEstimateCN);
                item.Left.CountCN.Should().Be(item.Right.CountCN);
                item.Left.KPI.Should().Be(item.Right.KPI);
                item.Left.Time.Should().Be(item.Right.Time);
            }
        }
Beispiel #2
0
        public void SerializeDeserialize_Test()
        {
            var tallyHistoryCollection = new TallyHistoryCollection(10);

            var count = new CountTree()
            {
                CountTree_CN = 1
            };
            var tree = new Tree()
            {
                Tree_CN = 2
            };
            var treeEstimate = new TreeEstimateDO()
            {
                TreeEstimate_CN = 3
            };
            var kpiValue  = 1234;
            var timeValue = "123";

            tallyHistoryCollection.Add(new TallyAction()
            {
                Count        = count,
                Time         = timeValue,
                KPI          = kpiValue,
                TreeRecord   = tree,
                TreeEstimate = treeEstimate
            });

            var xmlText = tallyHistoryCollection.Serialize();

            var resultCollection = TallyHistoryCollection.Deserialize(xmlText);

            resultCollection.Should().HaveSameCount(tallyHistoryCollection);

            var resultItem = resultCollection.First();

            resultItem.TreeCN.Should().Be(tree.Tree_CN);
            resultItem.TreeEstimateCN.Should().Be(treeEstimate.TreeEstimate_CN);
            resultItem.CountCN.Should().Be(count.CountTree_CN);
            resultItem.KPI.Should().Be(kpiValue);
            resultItem.Time.Should().Be(timeValue);
        }