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); }
public override async Task ExecuteAsync(EasyDb db) { try { await db.InsertAsync <User>(new User { UserName = "******" }); await db.InsertAsync <User>(new User { UserName = "******" }); await db.InsertAsync <User>(new User { UserName = "******" }); } catch (System.Exception ex) { throw ex; } }
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); }
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; } }
public async Task Insert_WithFactory() { var db = new EasyDb(); db.SetConnectionStringSettings(DbConstants.SqlDb1, DbConstants.SqlProviderName); db.DefaultMappingBehavior = DefaultMappingBehavior.CreateEmptyTable; var user = new User { UserName = "******" }; var result = await db.InsertAsync <User>(new UserInsertFactory(), user); Assert.AreEqual(6, result); Assert.AreEqual(6, user.Id); }