public void TestVMHExportImport() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "Noam"); mt.InsertRow(2, 2, "Yael"); var vmh = new ViewModel() { From = mt }; var dl = vmh.ExportRows(); mt.Truncate(); mt.CountRows().ShouldBe(0); vmh = new ViewModel() { From = mt }; vmh.ImportRows(dl); var i = 0; mt.ForEachRow(null, new Sort(mt.a), () => { mt.a.ShouldBe(new Number[] { 1, 2 }[i]); mt.b.ShouldBe(new Number[] { 1, 2 }[i]); mt.c.ShouldBe(new string[] { "Noam", "Yael" }[i]); i++; }).ShouldBe(2); }
public void TestViewModelHelper_0() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "noam"); mt.InsertRow(2, 2, "yael"); var vmc = new TestVMH(); var dl = vmc.GetRows(); dl.Count.ShouldBe(2); dl[0]["id"].Number.ShouldBe(1); dl[1]["id"].Number.ShouldBe(2); dl[0]["c2"].Number.ShouldBe(1); dl[0]["c3"].Text.ShouldBe("noam"); }
public void TestViewModelHelper_post() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "noam"); mt.InsertRow(2, 2, "yael"); var vmc = new TestVMH(); var i = new DataItem(); i.Set("c2", 2); i.Set("c3", "yael"); i = vmc.Insert(i); mt.CountRows().ShouldBe(3); i["id"].Number.ShouldBe(3); }
public void TestViewModelHelper_2() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "noam"); mt.InsertRow(2, 2, "yael"); var vmc = new TestVMH(); var item = vmc.GetRows(); vmc.Delete(item[0]["id"].Text); mt.CountRows().ShouldBe(1); new BusinessProcess { From = mt }.ForFirstRow(() => mt.c.ShouldBe("yael")); }
public void TestViewModelHelper_1() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "noam"); mt.InsertRow(2, 2, "yael"); var vmc = new TestVMH(); var item = vmc.GetRow("1"); item["id"].Number.ShouldBe(1); item["c2"].Number.ShouldBe(1); item["c3"].Text.ShouldBe("noam"); item.Set("c3", "yoni"); item = vmc.Update("1", item); item["c3"].Text.ShouldBe("yoni"); mt.GetValue(mt.c, mt.a.IsEqualTo(1)).ShouldBe("yoni"); }
public void TestHandlingOfDuplicateRows() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "Noam"); mt.InsertRow(2, 2, "Yael"); mt.InsertRow(3, 3, "Yoni"); var vmh = new ViewModel { From = mt }; var d = vmh.ExportRows(); mt.Delete(mt.a.IsDifferentFrom(2)); mt.CountRows().ShouldBe(1); vmh.ImportRows(d, ignoreDuplicateRows: true); mt.CountRows().ShouldBe(3); }
public void TestInsertOneRow() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "Noam"); mt.InsertRow(2, 2, "Yael"); mt.InsertRow(3, 3, "Yoni"); var vmh = new ViewModel { From = mt }; var d = vmh.ExportRows(); mt.Truncate(); mt.CountRows().ShouldBe(0); vmh.Insert(d[0]); mt.CountRows().ShouldBe(1); }
public void TestViewModelHelper_BigPrimaryKey() { var mt = new MockTable(); mt.Truncate(); mt.InsertRow(1, 1, "noam"); mt.InsertRow(2, 2, "yael"); var vmc = new TestVMHWithMoreThanOneMemoberInThePrimaryKey(); var dl = vmc.GetRows(); dl.Count.ShouldBe(2); dl[0]["c1"].Number.ShouldBe(1); dl[1]["c1"].Number.ShouldBe(2); dl[0]["c2"].Number.ShouldBe(1); dl[0]["c3"].Text.ShouldBe("noam"); var item = vmc.GetRow(dl[0]["id"].Text); item["c1"].Number.ShouldBe(1); }