Exemple #1
0
        public async Task PendingTransaction_Fail()
        {
            var db = new EasyDb();

            db.SetConnectionStringSettings(DbConstants.SqlDb1, DbConstants.SqlProviderName);

            db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable;

            db.AddPendingOperation(() => db.InsertAsync <User>(new User {
                UserName = "******"
            }));

            // constraint on user permission
            var user = await db.SelectOneAsync <User>(Check.Op("Id", 1));

            db.AddPendingOperation(() => db.DeleteAsync <User>(user, Check.Op("Id", 1)));

            Assert.AreEqual(2, db.PendingOperations.Count);

            var result = await db.ExecutePendingOperationsAsync();



            Assert.IsFalse(result);
            Assert.AreEqual(2, db.PendingOperations.Count);
        }
Exemple #2
0
        public async Task PendingTransaction()
        {
            var db = new EasyDb();

            db.SetConnectionStringSettings(DbConstants.SqlDb1, DbConstants.SqlProviderName);

            db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable;

            db.AddPendingOperation(() => db.InsertAsync <User>(new User {
                UserName = "******"
            }));
            db.AddPendingOperation(() => db.InsertAsync <User>(new User {
                UserName = "******"
            }));
            db.AddPendingOperation(() => db.InsertAsync <User>(new User {
                UserName = "******"
            }));

            Assert.AreEqual(3, db.PendingOperations.Count);

            var result = await db.ExecutePendingOperationsAsync();

            Assert.IsTrue(result);
            Assert.AreEqual(0, db.PendingOperations.Count);
        }