public void Test()
        {
            var spec = entitySpec.Begin()
                       .Add(entitySpec.Begin("SelfList").NotSaved()
                            .Add("Double"))
                       .Add("AggregatedDouble").Aggregates("SelfList.Double")
                       .Add("FormulaOnAggregate").Formula("2*AggregatedDouble");

            var theTop = new TheTop
            {
                SelfList = new List <TheTop> {
                    new TheTop {
                        Double = 42
                    }, new TheTop {
                        Double = 43
                    }
                }
            };
            var t      = new InMemoryTableManager();
            var export = new DataExtract <TheTop>(spec, t);

            _topEntity = export.TopEntity;
            export.Run(theTop);
            _tables = export.TableManager.GetWithAllData();

            _topTable = _tables.Single(_ => _.Name == "TheTop");
        }
        public void Test()
        {
            var spec = entitySpec.Begin()
                       .Add("FirstName")
                       .Add("AggregatedX").Aggregates("Structs.X")
                       .Add(entitySpec.Begin("Structs").NotSaved()
                            .Add("X"))
                       .Add(entitySpec.Begin("Self.SelfList")
                            .Add("Double"))
                       .Add("AggregatedDouble").Aggregates("Self.SelfList.Double");

            var theTop = new TheTop
            {
                FirstName = "Petronella",
                Structs   = Enumerable.Range(1, 4).Select(_ => new SomeStruct {
                    X = _
                }).ToList(),
                SomeStruct = new SomeStruct {
                    X = 7, Y = 8
                },
                Self = new TheTop
                {
                    SelfList = new List <TheTop> {
                        new TheTop {
                            Double = 42
                        }, new TheTop {
                            Double = 43
                        }
                    }
                }
            };
            var t      = new InMemoryTableManager();
            var export = new DataExtract <TheTop>(spec, t);

            _topEntity = export.TopEntity;
            export.Run(theTop);
            _tables = export.TableManager.GetWithAllData();

            _topTable = _tables.Single(_ => _.Name == "TheTop");
        }
Esempio n. 3
0
        public void TestFiltering(string whereClause, int expectedRowCount)
        {
            var spec = entitySpec.Begin()
                       .Add(entitySpec.Begin("SelfList").Where(whereClause)
                            .Add("SumXY").Formula("SomeStruct.X+SomeStruct.Y")
                            .Add("SomeStruct.X")
                            .Add("SomeStruct.Y"));

            var theTop = new TheTop
            {
                SelfList = new List <TheTop>
                {
                    new TheTop {
                        SomeStruct = new SomeStruct {
                            X = 42, Y = 43
                        }
                    },
                    new TheTop {
                        SomeStruct = new SomeStruct {
                            X = 3, Y = 3
                        }
                    },
                    new TheTop {
                        SomeStruct = new SomeStruct {
                            X = 16, Y = 13
                        }
                    },
                }
            };
            var export = new DataExtract <TheTop>(spec);

            export.Run(theTop);
            var tables        = export.TableManager.GetWithAllData();
            var filteredTable = tables.Single(_ => _.Name == "SelfList");

            Assert.AreEqual(expectedRowCount, filteredTable.Rows.Count);
        }