Ejemplo n.º 1
0
        public void AddDeleteCars()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("car");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Cars = tm.GetResourceMananger("car");

            var context = wc.Start();

            Assert.IsTrue(wc.AddCars(context, "SEATTLE", 100, 66));
            Assert.IsTrue(wc.AddCars(context, "HONOLULU", 200, 220));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(66, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(200, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(220, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);

            //add rooms
            context = wc.Start();
            Assert.IsTrue(wc.AddCars(context, "SEATTLE", 10, 55));
            Assert.IsTrue(wc.AddCars(context, "HONOLULU", 20, 110));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100 + 10, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(55, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(220, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(110, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);

            //delete rooms
            context = wc.Start();
            Assert.IsTrue(wc.DeleteCars(context, "SEATTLE", 5));
            Assert.IsTrue(wc.DeleteCars(context, "HONOLULU", 10));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100 + 10 - 5, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(55, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(220 - 10, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(110, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);
        }
Ejemplo n.º 2
0
        public void AddDeleteCars()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("car");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Cars = tm.GetResourceMananger("car");

            var context = wc.Start();
            Assert.IsTrue(wc.AddCars(context, "SEATTLE", 100, 66));
            Assert.IsTrue(wc.AddCars(context, "HONOLULU", 200, 220));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(66, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(200, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(220, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);

            //add rooms
            context = wc.Start();
            Assert.IsTrue(wc.AddCars(context, "SEATTLE", 10, 55));
            Assert.IsTrue(wc.AddCars(context, "HONOLULU", 20, 110));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100 + 10, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(55, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(220, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(110, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);

            //delete rooms
            context = wc.Start();
            Assert.IsTrue(wc.DeleteCars(context, "SEATTLE", 5));
            Assert.IsTrue(wc.DeleteCars(context, "HONOLULU", 10));
            wc.Commit(context);

            context = wc.Start();
            Assert.AreEqual(100 + 10 - 5, wc.QueryCar(context, "SEATTLE"));
            Assert.AreEqual(55, wc.QueryCarPrice(context, "SEATTLE"));

            Assert.AreEqual(220 - 10, wc.QueryCar(context, "HONOLULU"));
            Assert.AreEqual(110, wc.QueryCarPrice(context, "HONOLULU"));
            wc.Commit(context);
        }