示例#1
0
        public void LoadTest5()
        {
            using (SoodaTransaction tran = new SoodaTransaction())
            {
                BikeList list = Bike.GetList(tran, SoodaWhereClause.Unrestricted);
                foreach (Vehicle v in list)
                {
                    if (v != null)
                    {
                    }
                    // shouldn't throw
                }
                foreach (Bike v in list)
                {
                    if (v != null)
                    {
                    }
                    // shouldn't throw
                }

                //
                // there are 7 bikes out of 9 vehicles and Bike.GetList
                // should filter them properly
                //
                Assert.AreEqual(7, list.Count);
            }
        }
        public void Test10()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                SoodaInProcessCache myCache = new SoodaInProcessCache();
                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);
                    tran.Cache         = myCache;
                    tran.CachingPolicy = new SoodaCacheAllPolicy();

                    string      ck1 = SoodaCache.GetCollectionKey("Vehicle", new SoodaWhereClause(true));
                    VehicleList c1  = Vehicle.GetList(true);

                    string   ck2 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(true));
                    BikeList c2  = Bike.GetList(true);

                    string   ck3 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(false));
                    BikeList c3  = Bike.GetList(false);

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));

                    myCache.Evict("Vehicle", 1);

                    // ck2 is not evicted because vehicle[1] is not a bike
                    // ck3 is not evicted because it contains zero objects

                    Assert.IsNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));
                }
            }
        }
        public void Test11()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                SoodaInProcessCache myCache = new SoodaInProcessCache();
                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);
                    tran.Cache         = myCache;
                    tran.CachingPolicy = new SoodaCacheAllPolicy();

                    string      ck1 = SoodaCache.GetCollectionKey("Vehicle", new SoodaWhereClause(true));
                    VehicleList c1  = Vehicle.GetList(true, SoodaSnapshotOptions.KeysOnly);

                    string   ck2 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(true));
                    BikeList c2  = Bike.GetList(true, SoodaSnapshotOptions.KeysOnly);

                    string   ck3 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(false));
                    BikeList c3  = Bike.GetList(false, SoodaSnapshotOptions.KeysOnly);

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));

                    myCache.Evict("Vehicle", 1);

                    // nothing is evicted from collection cache because we requested KeysOnly

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));
                }
            }
        }
 public OrderTest()
 {
     bikeList = new BikeList();
 }