예제 #1
0
        public void DeleteFlight()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight_001");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight_001");

            var context = tm.Start();

            Assert.IsTrue(wc.AddSeats(context, "FLK", 100, 550));
            tm.Commit(context);

            context = tm.Start();
            var result = wc.ListFlights(context);

            tm.Commit(context);

            Assert.IsTrue((from f in result where f == "FLK,100,550" select f).Any());

            context = tm.Start();
            Assert.IsTrue(wc.DeleteFlight(context, "FLK"));
            result = wc.ListFlights(context);
            tm.Commit(context);

            Assert.IsFalse((from f in result where f == "FLK,100,550" select f).Any());
        }
예제 #2
0
        public void AddSeatsTwoTransactions()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context1 = new Transaction();
            var context2 = new Transaction();

            wc.AddSeats(context1, "FL_C", 100, 550);
            wc.AddSeats(context2, "SG_A", 200, 250);
            wc.Abort(context2);
            wc.Commit(context1);

            context1 = new Transaction();
            var result = wc.ListFlights(context1);

            wc.Commit(context1);
            Assert.IsTrue((from f in result where f == "FL_C,100,550" select f).Any());
            Assert.IsFalse((from f in result where f == "SG_A,200,250" select f).Any());
        }
예제 #3
0
        public void DeleteSeatsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight_000");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight_000");

            var context = wc.Start();
            var flights = wc.ListFlights(context);

            foreach (var f in flights)
            {
                wc.DeleteFlight(context, f.Split(',')[0]);
            }
            wc.Commit(context);

            context = wc.Start();
            Assert.IsTrue(wc.AddSeats(context, "FLX", 100, 550));
            Assert.IsTrue(wc.AddSeats(context, "SGX", 200, 250));
            wc.Commit(context);

            context = wc.Start();
            var result = wc.ListFlights(context);

            wc.Commit(context);
            Assert.AreEqual(2, result.Length);

            context = wc.Start();
            Assert.IsTrue(wc.DeleteSeats(context, "FLX", 50));
            Assert.IsTrue(wc.DeleteSeats(context, "SGX", 50));
            wc.Commit(context);

            context = wc.Start();
            var c1 = wc.QueryFlight(context, "FLX");
            var c2 = wc.QueryFlight(context, "SGX");

            Assert.AreEqual(100 - 50, c1);
            Assert.AreEqual(200 - 50, c2);
            wc.Abort(context);
        }
예제 #4
0
        public void AddSeatsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context = wc.Start();

            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.Commit(context);

            context = wc.Start();
            var result = wc.ListFlights(context);

            wc.Commit(context);
            Assert.AreEqual(2, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 50, 450);
            wc.Commit(context);

            context = wc.Start();
            var c = wc.QueryFlight(context, "FL");

            Assert.AreEqual(150, c);
            var price = wc.QueryFlightPrice(context, "FL");

            Assert.AreEqual(450, price);
            wc.Abort(context);

            context = wc.Start();
            c       = wc.QueryFlight(context, "SG");
            price   = wc.QueryFlightPrice(context, "SG");
            Assert.AreEqual(200, c);
            Assert.AreEqual(250, price);
            wc.Abort(context);
        }
예제 #5
0
        public void AddManyFlightsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();

            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context = wc.Start();

            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.AddSeats(context, "SG1", 201, 251);
            wc.AddSeats(context, "SG2", 202, 252);
            wc.AddSeats(context, "SG3", 203, 253);
            wc.AddSeats(context, "SG4", 204, 254);
            wc.AddSeats(context, "SG5", 205, 255);
            wc.AddSeats(context, "SG5", 206, 256);
            wc.AddSeats(context, "SG6", 207, 257);
            wc.Abort(context);

            context = wc.Start();
            var result = wc.ListFlights(context);

            wc.Commit(context);
            Assert.AreEqual(0, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.AddSeats(context, "SG1", 201, 251);
            wc.AddSeats(context, "SG2", 202, 252);
            wc.AddSeats(context, "SG3", 203, 253);
            wc.AddSeats(context, "SG4", 204, 254);
            wc.AddSeats(context, "SG5", 205, 255);
            wc.AddSeats(context, "SG5", 206, 256);
            wc.AddSeats(context, "SG6", 207, 257);
            wc.Commit(context);

            context = wc.Start();
            result  = wc.ListFlights(context);
            wc.Commit(context);
            Assert.AreEqual(8, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 50, 450);
            wc.Commit(context);

            context = wc.Start();
            var c = wc.QueryFlight(context, "FL");

            Assert.AreEqual(150, c);
            var price = wc.QueryFlightPrice(context, "FL");

            Assert.AreEqual(450, price);
            wc.Abort(context);

            context = wc.Start();
            c       = wc.QueryFlight(context, "SG");
            price   = wc.QueryFlightPrice(context, "SG");
            Assert.AreEqual(200, c);
            Assert.AreEqual(250, price);
            wc.Abort(context);

            context = wc.Start();
            c       = wc.QueryFlight(context, "SG5");
            price   = wc.QueryFlightPrice(context, "SG5");
            Assert.AreEqual(411, c);
            Assert.AreEqual(256, price);
            wc.Abort(context);
        }
예제 #6
0
        public void DeleteSeatsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight_000");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight_000");

            var context = wc.Start();
            var flights = wc.ListFlights(context);
            foreach(var f in flights)
            {
                wc.DeleteFlight(context, f.Split(',')[0]);
            }
            wc.Commit(context);

            context = wc.Start();
            Assert.IsTrue(wc.AddSeats(context, "FLX", 100, 550));
            Assert.IsTrue(wc.AddSeats(context, "SGX", 200, 250));
            wc.Commit(context);

            context = wc.Start();
            var result = wc.ListFlights(context);
            wc.Commit(context);
            Assert.AreEqual(2, result.Length);

            context = wc.Start();
            Assert.IsTrue(wc.DeleteSeats(context, "FLX", 50));
            Assert.IsTrue(wc.DeleteSeats(context, "SGX", 50));
            wc.Commit(context);

            context = wc.Start();
            var c1 = wc.QueryFlight(context, "FLX");
            var c2 = wc.QueryFlight(context, "SGX");
            Assert.AreEqual(100 - 50, c1);
            Assert.AreEqual(200 - 50, c2);
            wc.Abort(context);
        }
예제 #7
0
        public void DeleteFlight()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight_001");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight_001");

            var context = tm.Start();
            Assert.IsTrue(wc.AddSeats(context, "FLK", 100, 550));
            tm.Commit(context);

            context = tm.Start();
            var result = wc.ListFlights(context);
            tm.Commit(context);

            Assert.IsTrue((from f in result where f == "FLK,100,550" select f).Any());

            context = tm.Start();
            Assert.IsTrue(wc.DeleteFlight(context, "FLK"));
            result = wc.ListFlights(context);
            tm.Commit(context);

            Assert.IsFalse((from f in result where f == "FLK,100,550" select f).Any());
        }
예제 #8
0
        public void AddSeatsTwoTransactions()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context1 = new Transaction();
            var context2 = new Transaction();
            wc.AddSeats(context1, "FL_C", 100, 550);
            wc.AddSeats(context2, "SG_A", 200, 250);
            wc.Abort(context2);
            wc.Commit(context1);

            context1 = new Transaction();
            var result = wc.ListFlights(context1);
            wc.Commit(context1);
            Assert.IsTrue((from f in result where f == "FL_C,100,550" select f).Any());
            Assert.IsFalse((from f in result where f == "SG_A,200,250" select f).Any());
        }
예제 #9
0
        public void AddSeatsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context = wc.Start();
            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.Commit(context);

            context = wc.Start();
            var result = wc.ListFlights(context);
            wc.Commit(context);
            Assert.AreEqual(2, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 50, 450);
            wc.Commit(context);

            context = wc.Start();
            var c = wc.QueryFlight(context, "FL");
            Assert.AreEqual(150, c);
            var price = wc.QueryFlightPrice(context, "FL");
            Assert.AreEqual(450, price);
            wc.Abort(context);

            context = wc.Start();
            c = wc.QueryFlight(context, "SG");
            price = wc.QueryFlightPrice(context, "SG");
            Assert.AreEqual(200, c);
            Assert.AreEqual(250, price);
            wc.Abort(context);
        }
예제 #10
0
        public void AddManyFlightsTest()
        {
            var wc = new MyWC.MyWC_Accessor();
            var tm = new MyTM.MyTM();
            var rm = new MyRM.MyRM();
            MyWC_Accessor.TransactionManager = tm;
            rm.SetName("flight");
            rm.TransactionManager = tm;
            tm.Register(rm);
            MyWC.MyWC.Flights = tm.GetResourceMananger("flight");

            var context = wc.Start();
            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.AddSeats(context, "SG1", 201, 251);
            wc.AddSeats(context, "SG2", 202, 252);
            wc.AddSeats(context, "SG3", 203, 253);
            wc.AddSeats(context, "SG4", 204, 254);
            wc.AddSeats(context, "SG5", 205, 255);
            wc.AddSeats(context, "SG5", 206, 256);
            wc.AddSeats(context, "SG6", 207, 257);
            wc.Abort(context);

            context = wc.Start();
            var result = wc.ListFlights(context);
            wc.Commit(context);
            Assert.AreEqual(0, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 100, 550);
            wc.AddSeats(context, "SG", 200, 250);
            wc.AddSeats(context, "SG1", 201, 251);
            wc.AddSeats(context, "SG2", 202, 252);
            wc.AddSeats(context, "SG3", 203, 253);
            wc.AddSeats(context, "SG4", 204, 254);
            wc.AddSeats(context, "SG5", 205, 255);
            wc.AddSeats(context, "SG5", 206, 256);
            wc.AddSeats(context, "SG6", 207, 257);
            wc.Commit(context);

            context = wc.Start();
            result = wc.ListFlights(context);
            wc.Commit(context);
            Assert.AreEqual(8, result.Length);

            context = wc.Start();
            wc.AddSeats(context, "FL", 50, 450);
            wc.Commit(context);

            context = wc.Start();
            var c = wc.QueryFlight(context, "FL");
            Assert.AreEqual(150, c);
            var price = wc.QueryFlightPrice(context, "FL");
            Assert.AreEqual(450, price);
            wc.Abort(context);

            context = wc.Start();
            c = wc.QueryFlight(context, "SG");
            price = wc.QueryFlightPrice(context, "SG");
            Assert.AreEqual(200, c);
            Assert.AreEqual(250, price);
            wc.Abort(context);

            context = wc.Start();
            c = wc.QueryFlight(context, "SG5");
            price = wc.QueryFlightPrice(context, "SG5");
            Assert.AreEqual(411, c);
            Assert.AreEqual(256, price);
            wc.Abort(context);
        }