Пример #1
0
        public void PolymorphicQueryWithFilter()
        {
            dataStore = CreateDataStore();
            dataStore.Settings.AutoGenerate = true;

            try {
                dataStore.DeleteStorage(typeof(Circle));
            } catch {}
            dataStore.CreateStorage(typeof(Circle));

            try {
                dataStore.DeleteStorage(typeof(Rectangle));
            } catch {}
            dataStore.CreateStorage(typeof(Rectangle));

            Circle c = new Circle();
            c.Color = "Green";
            c.Radius = 5;
            dataStore.Insert(c);

            Rectangle r = new Rectangle();
            r.Color = "Green";
            r.Width = 5;
            r.Length = 2;
            dataStore.Insert(r);

            IList shapes = dataStore.CreateFindCollectionCommand(typeof(Shape), null, true).Execute();

            Assert.IsTrue(shapes.Count == 2,"Returned Items = " + shapes.Count);
            Assert.IsTrue(((Shape)shapes[0]).GetArea() == 2 * Math.PI * Math.Pow(5,2),"Circle Area");
            Assert.IsTrue(((Shape)shapes[1]).GetArea() == 10,"Rectangle Area");

            dataStore.DeleteStorage(typeof(Circle));
            dataStore.DeleteStorage(typeof(Rectangle));
            dataStore.DeleteStorage(typeof(Shape));
        }