示例#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);
        }
示例#2
0
        public async Task Delete()
        {
            var db = new EasyDb();

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

            db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable;

            var model = await db.SelectOneAsync <User>(Check.Op("Id", 3));

            var result = await db.DeleteAsync <User>(model, Check.Op("Id", 3));

            Assert.AreEqual(1, result);
        }
        public override async Task ExecuteAsync(EasyDb db)
        {
            try
            {
                await db.InsertAsync <User>(new User { UserName = "******" });

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

                // constraint on user permission
                await db.DeleteAsync <User>(user, Check.Op("Id", 1));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public async Task Delete_WithFactory()
        {
            var db = new EasyDb();

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

            db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable;

            var post = new Post
            {
                Id = 1
            };

            int result = await db.DeleteAsync <Post>(new DeleteUserFactory(), post);

            Assert.AreEqual(1, result);
        }