コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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"));
        }