示例#1
0
        public void TestDescendantsAndSelfQueryTree() {
            List<StringValue> values = new List<StringValue>() {
                new StringValue() {
                    Data = "0"
                },
                new StringValue() {
                    Data = "1"
                },
                new StringValue() {
                    Data = "2"
                },
                new StringValue() {
                    Data = "3"
                }
            };

            // Create a tree of values. We will want to flatten and find each value after.
            IDatabaseObject query = new Find()
                .Method(
                    values[0]
                )
                .Method(
                    values[1]
                )
                .Method(
                    new Drop()
                    .Field(
                        values[2]
                        .Method(
                            new Save()
                            .Field(
                                values[3]
                            )
                        )
                    )
                );

            List<StringValue> descendants = query.DescendantsAndSelf<StringValue>().ToList();

            Assert.AreEqual(4, descendants.Count());
            
            foreach (StringValue item in descendants) {
                Assert.IsTrue(values.Contains(item));    
            }
        }