public static void ASYNC_QueryInsertQuery(ICRUDDataStore store) { var query = new Query("CRUD.Patient.List") { new Query.Param("LN", "%loff") }; var task = store.LoadAsync(query); Assert.AreEqual(1, task.Result.Count); var rowset = task.Result[0]; Assert.AreEqual(0, rowset.Count); var row = new DynamicRow(rowset.Schema); row["ssn"] = "999-88-9012"; row["First_Name"] = "Jack"; row["Last_Name"] = "Kozloff"; row["DOB"] = new DateTime(1980, 1, 12); Assert.IsNull(row.Validate()); store.InsertAsync(row).Wait(); task = store.LoadAsync(query); Assert.AreEqual(1, task.Result.Count); rowset = task.Result[0]; Assert.AreEqual(1, rowset.Count); Assert.AreEqual("Jack", rowset[0]["First_Name"]); }
public static void ASYNC_QueryInsertQuery(ICRUDDataStore store) { var query = new Query("CRUD.Patient.List") { new Query.Param("LN", "%loff") }; var task = store.LoadAsync( query ); Assert.AreEqual(1, task.Result.Count); var rowset = task.Result[0]; Assert.AreEqual(0, rowset.Count); var row = new DynamicRow(rowset.Schema); row["ssn"] = "999-88-9012"; row["First_Name"] = "Jack"; row["Last_Name"] = "Kozloff"; row["DOB"] = new DateTime(1980, 1, 12); Assert.IsNull( row.Validate()); store.InsertAsync(row).Wait(); task = store.LoadAsync( query ); Assert.AreEqual(1, task.Result.Count); rowset = task.Result[0]; Assert.AreEqual(1, rowset.Count); Assert.AreEqual("Jack", rowset[0]["First_Name"]); }
public static void ASYNC_InsertThenUpdate_TypedRow(ICRUDDataStore store) { for (var i = 0; i < 10; i++) { store.InsertAsync(new Patient { SSN = i.ToString(), First_Name = "Jack", Last_Name = "Kozloff_" + i, DOB = new DateTime(1980, 1, 12) }).Wait(); } var result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Assert.AreEqual(1, result.Count); var row = result[0] as Patient; Assert.AreEqual("5", row.SSN); row.Last_Name = "Gagarin"; store.UpdateAsync(row).Wait(); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Assert.AreEqual(0, result.Count); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%garin") })[0]; Assert.AreEqual(1, result.Count); Assert.AreEqual("5", result[0]["SSN"]); Assert.AreEqual("Gagarin", result[0]["Last_Name"]); }
public static void ASYNC_InsertThenDelete_TypedRow(ICRUDDataStore store) { for (var i = 0; i < 10; i++) { store.InsertAsync(new Patient { SSN = i.ToString(), First_Name = "Jack", Last_Name = "Kozloff_" + i, DOB = new DateTime(1980, 1, 12) }).Wait(); } var result = store.Load(new Query("CRUD.Queries.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Aver.AreEqual(1, result.Count); var row = result[0] as Patient; Aver.AreEqual("5", row.SSN.Trim()); store.DeleteAsync(row).Wait(); result = store.Load(new Query("CRUD.Queries.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Aver.AreEqual(0, result.Count); result = store.Load(new Query("CRUD.Queries.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_%") })[0]; Aver.AreEqual(9, result.Count); }
public static void ASYNC_InsertThenUpsert_TypedRow(ICRUDDataStore store) { for(var i=0; i<10; i++) { store.InsertAsync( new Patient { SSN = i.ToString(), First_Name = "Jack", Last_Name = "Kozloff_"+i, DOB = new DateTime(1980, 1, 12) }).Wait(); } var result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0]; Assert.AreEqual(1, result.Count); var row = result[0] as Patient; Assert.AreEqual("5", row.SSN); Assert.AreEqual(null, row.Phone); row.Phone = "22-94-92"; store.UpsertAsync( row ).Wait(); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0]; Assert.AreEqual(1, result.Count); Assert.AreEqual("22-94-92", result[0]["Phone"]); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_%") } )[0]; Assert.AreEqual(10, result.Count); row = new Patient { SSN = "-100", First_Name = "Vlad", Last_Name = "Lenin", DOB = new DateTime(1871, 4, 20) }; store.UpsertAsync(row).Wait(); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%") } )[0]; Assert.AreEqual(11, result.Count); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "Lenin") } )[0]; Assert.AreEqual(1, result.Count); Assert.AreEqual("Vlad", result[0]["First_Name"]); }
public static void ASYNC_InsertThenDelete_TypedRow(ICRUDDataStore store) { for(var i=0; i<10; i++) { store.InsertAsync( new Patient { SSN = i.ToString(), First_Name = "Jack", Last_Name = "Kozloff_"+i, DOB = new DateTime(1980, 1, 12) }).Wait(); } var result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0]; Assert.AreEqual(1, result.Count); var row = result[0] as Patient; Assert.AreEqual("5", row.SSN); store.DeleteAsync( row ).Wait(); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_5") } )[0]; Assert.AreEqual(0, result.Count); result = store.Load( new Query("CRUD.Patient.List", typeof(Patient) ) { new Query.Param("LN", "%loff_%") } )[0]; Assert.AreEqual(9, result.Count); }
public static void ASYNC_InsertThenUpsert_TypedRow(ICRUDDataStore store) { for (var i = 0; i < 10; i++) { store.InsertAsync(new Patient { SSN = i.ToString(), First_Name = "Jack", Last_Name = "Kozloff_" + i, DOB = new DateTime(1980, 1, 12) }).Wait(); } var result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Assert.AreEqual(1, result.Count); var row = result[0] as Patient; Assert.AreEqual("5", row.SSN); Assert.AreEqual(null, row.Phone); row.Phone = "22-94-92"; store.UpsertAsync(row).Wait(); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_5") })[0]; Assert.AreEqual(1, result.Count); Assert.AreEqual("22-94-92", result[0]["Phone"]); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%loff_%") })[0]; Assert.AreEqual(10, result.Count); row = new Patient { SSN = "-100", First_Name = "Vlad", Last_Name = "Lenin", DOB = new DateTime(1871, 4, 20) }; store.UpsertAsync(row).Wait(); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "%") })[0]; Assert.AreEqual(11, result.Count); result = store.Load(new Query("CRUD.Patient.List", typeof(Patient)) { new Query.Param("LN", "Lenin") })[0]; Assert.AreEqual(1, result.Count); Assert.AreEqual("Vlad", result[0]["First_Name"]); }