public async Task Save_MultipleRows() { var depts = new Departments(ProviderName); object[] toSave = new object[] { new { DNAME = "Massive Dep", LOC = "Beach" }.ToExpando(), new { DNAME = "Massive Dep", LOC = "DownTown" }.ToExpando() }; var result = await depts.SaveAsync(toSave); Assert.AreEqual(2, result); foreach (dynamic o in toSave) { Assert.IsTrue(o.DEPTNO > 0); } // read them back, update them, save them again, var savedDeps = await(await depts.AllAsync(where : "WHERE DEPTNO=:0 OR DEPTNO=:1", args: new object[] { ((dynamic)toSave[0]).DEPTNO, ((dynamic)toSave[1]).DEPTNO })).ToListAsync(); Assert.AreEqual(2, savedDeps.Count); savedDeps[0].LOC += "C"; savedDeps[1].LOC += "C"; result = await depts.SaveAsync(toSave); Assert.AreEqual(2, result); Assert.AreEqual(1, await depts.DeleteAsync(savedDeps[0].DEPTNO)); Assert.AreEqual(1, await depts.DeleteAsync(savedDeps[1].DEPTNO)); }
public async Task Insert_SingleRow() { var depts = new Departments(ProviderName); var inserted = await depts.InsertAsync(new { DNAME = "Massive Dep", LOC = "Beach" }); Assert.IsTrue(inserted.DEPTNO > 0); Assert.AreEqual(1, await depts.DeleteAsync(inserted.DEPTNO)); }
public async Task Save_SingleRow() { var depts = new Departments(ProviderName); dynamic toSave = new { DNAME = "Massive Dep", LOC = "Beach" }.ToExpando(); var result = await depts.SaveAsync(toSave); Assert.AreEqual(1, result); Assert.IsTrue(toSave.DEPTNO > 0); Assert.AreEqual(1, await depts.DeleteAsync(toSave.DEPTNO)); }
public async Task UpdateUsing_SingleRow() { var depts = new Departments(ProviderName); dynamic toSave = new { DNAME = "Massive Dep", LOC = "Beach" }.ToExpando(); var saveResult = await depts.SaveAsync(toSave); Assert.AreEqual(1, saveResult); Assert.IsTrue(toSave.DEPTNO > 0); var mightyDep = new { DNAME = "Mighty Dep" }; Assert.AreEqual(0, (await(await depts.AllAsync(mightyDep)).ToListAsync()).Count); Assert.AreEqual(1, await depts.UpdateUsingAsync(mightyDep, toSave.DEPTNO)); Assert.AreEqual(1, (await(await depts.AllAsync(mightyDep)).ToListAsync()).Count); Assert.AreEqual(1, await depts.DeleteAsync(toSave.DEPTNO)); Assert.AreEqual(0, (await(await depts.AllAsync(mightyDep)).ToListAsync()).Count); }
public async Task Insert_SingleRow(Boolean explicitConnection) { var depts = new Departments(ProviderName, explicitConnection); DbConnection connection = null; if (explicitConnection) { MightyTests.ConnectionStringUtils.CheckConnectionStringRequiredForOpenConnectionAsync(depts); connection = await depts.OpenConnectionAsync(MightyTests.ConnectionStringUtils.GetConnectionString(TestConstants.ReadWriteTestConnection, ProviderName)); } using (connection) { var inserted = await depts.InsertAsync(new { DNAME = "Massive Dep", LOC = "Beach" }, connection : connection); Assert.IsTrue(inserted.DEPTNO > 0); Assert.AreEqual(1, await depts.DeleteAsync(connection, inserted.DEPTNO)); } }
public async Task CleanUp() { // delete all rows with department name 'Massive Dep'. var depts = new Departments(ProviderName); await depts.DeleteAsync("DNAME=:0", "Massive Dep"); }