Exemplo n.º 1
0
        public void AddTest()
        {
            MyRM.MyRM_Accessor rm      = MockRM("AddTest");
            Transaction        context = new Transaction();
            RID i     = new RID(RID.Type.ROOM, "test1");
            int count = 1;
            int price = 3;

            rm.Add(context, i, count, price);
            rm.Prepare(context);
            rm.Commit(context);
            Assert.AreEqual(price, rm.QueryPrice(context, i));
        }
Exemplo n.º 2
0
        public void UnReserveTest()
        {
            MyRM.MyRM_Accessor rm      = MockRM("UnReserveTest");
            Transaction        context = new Transaction();
            Customer           c       = new Customer();
            RID rid   = new RID(RID.Type.ROOM, "test1");
            RID rid1  = new RID(RID.Type.CAR, "test1");
            int count = 5;
            int price = 3;

            Assert.IsFalse(rm.Delete(context, rid));
            rm.Add(context, rid, count, price);
            rm.Add(context, rid1, count, price);
            rm.Reserve(context, c, rid);
            Assert.AreEqual(count, rm.Query(context, rid1));
            Assert.AreEqual(count - 1, rm.Query(context, rid));
            rm.UnReserve(context, c);
            Assert.AreEqual(count, rm.Query(context, rid1));
            Assert.AreEqual(count, rm.Query(context, rid));
        }
Exemplo n.º 3
0
        public void DeleteTest()
        {
            string rmName = "DeleteTest" + Guid.NewGuid();

            MyRM.MyRM_Accessor rm      = MockRM(rmName);
            Transaction        context = new Transaction();
            Customer           c       = new Customer();
            RID rid   = new RID(RID.Type.ROOM, "test1");
            int count = 5;
            int price = 3;

            Assert.IsFalse(rm.Delete(context, rid));
            rm.Add(context, rid, count, price);
            rm.Delete(context, rid, 2);
            Assert.AreEqual(3, rm.Query(context, rid));
            rm.Reserve(context, c, rid);
            rm.Delete(context, rid);
            Assert.AreEqual(0, rm.QueryReservedPrice(context, c));
            Assert.IsTrue(string.IsNullOrEmpty(rm.QueryReserved(context, c)));
            rm.Query(context, rid);
            Assert.Fail("shall not hit this line.");
        }
Exemplo n.º 4
0
 public void EnlistTest()
 {
     MyRM.MyRM_Accessor rm = MockRM();
     rm.Enlist(new Transaction());
 }