Пример #1
0
        public void Test3()
        {
            TransferRule aTr       = MakeTransferRule();
            ITableFilter theTarget = new TLeaveRequestFilter.TLeaveRequestFilter();

            theTarget.ConfigTheFilter(aTr, _MainTableName, _RestoreDbName, _TempDbName, _RestoreDbName, _TempDbName);
            MockAddLeaveRequest();
            Console.WriteLine("筛选数据");
            string target21 = theTarget.FilterTableData(new DateTime(2009, 6, 15), new DateTime(2009, 6, 16));

            Console.WriteLine(target21);
            Console.WriteLine("进行还原");
            string target22 = theTarget.RestoreTableData(new DateTime(2009, 6, 15), new DateTime(2009, 6, 16));

            Console.WriteLine(target22);

            Assert.IsTrue(target22.Contains("表TLeaveRequestFlow共计:增加1行,覆盖0行,删除0行"));
            Assert.IsTrue(target22.Contains("表TLeaveRequestItem共计:增加1行,覆盖0行,删除0行"));
            Assert.IsTrue(target22.Contains("表TLeaveRequest共计:增加1行,覆盖0行,删除0行"));
        }
Пример #2
0
        public void Test2()
        {
            TransferRule aTr       = MakeTransferRule();
            ITableFilter theTarget = new TLeaveRequestFilter.TLeaveRequestFilter();

            theTarget.ConfigTheFilter(aTr, _MainTableName, _RestoreDbName, _TempDbName, _RestoreDbName, _TempDbName);
            Assert.AreEqual(2, aTr.DbsToTransfer[0].ProtectTableNames.Count);

            //第一次测试:假设没有任何数据发生变化
            Console.WriteLine("第一次测试");
            Console.WriteLine("筛选数据");

            string target11 = theTarget.FilterTableData(new DateTime(2009, 6, 1), new DateTime(2009, 6, 30));

            Console.WriteLine(target11);
            Console.WriteLine("进行还原");
            string target12 = theTarget.RestoreTableData(new DateTime(2009, 6, 1), new DateTime(2009, 6, 30));

            Console.WriteLine(target12);
            //全部数据还原没有任何数据改变
            Assert.IsTrue(target12.Contains("表TLeaveRequest共计:增加0行,覆盖0行,删除0行"));
            Assert.IsTrue(target12.Contains("表TLeaveRequestItem共计:增加0行,覆盖0行,删除0行"));
            Assert.IsTrue(target12.Contains("表TLeaveRequestFlow共计:增加0行,覆盖0行,删除0行"));
            //第二次测试,分别模拟数据的增、删、改
            Console.WriteLine("第二次测试");
            MockChangment();
            Console.WriteLine("筛选数据");
            string target21 = theTarget.FilterTableData(new DateTime(2009, 6, 8), new DateTime(2009, 6, 13));

            Console.WriteLine(target21);
            Console.WriteLine("进行还原");
            string target22 = theTarget.RestoreTableData(new DateTime(2009, 6, 8), new DateTime(2009, 6, 13));

            Console.WriteLine(target22);

            //由于在Filter的时候已经过滤了TLeaveRequestFlow的2行数据,所以匹配之后将待还原数据库的2行数据也删除了
            Assert.IsTrue(target22.Contains("表TLeaveRequestFlow共计:增加1行,覆盖2行,删除2行"));
            Assert.IsTrue(target22.Contains("表TLeaveRequestItem共计:增加0行,覆盖0行,删除1行"));
            Assert.IsTrue(target22.Contains("表TLeaveRequest共计:增加0行,覆盖2行,删除0行"));
        }
Пример #3
0
        public void Test1()
        {
            //构建一个以TApplication为主的迁移策略,策略本身不会执行,仅仅是其中的一部分数据筛选功能进行测试
            TransferRule aTr       = MakeTransferRule();
            ITableFilter theTarget = new TLeaveRequestFilter.TLeaveRequestFilter();

            theTarget.ConfigTheFilter(aTr, _MainTableName, _RestoreDbName, _TempDbName, _TempDbName, _RestoreDbName);
            Assert.AreEqual(2, aTr.DbsToTransfer[0].ProtectTableNames.Count);

            string before = PrintAllTableInfo(aTr);

            Console.WriteLine("筛选之前的表信息");
            Console.WriteLine(before);

            string target = theTarget.FilterTableData(new DateTime(2009, 6, 8), new DateTime(2009, 6, 9));

            Console.WriteLine("进行筛选");
            Console.WriteLine(target);

            string after = PrintAllTableInfo(aTr);

            Console.WriteLine();
            Console.WriteLine("筛选之后的表信息");
            Console.WriteLine(after);

            Assert.IsTrue(before.Contains("表名:TLeaveRequest,最小ID:1,最大ID:2,总行数:2"));
            Assert.IsTrue(before.Contains("表名:TLeaveRequestItem,最小ID:1,最大ID:2,总行数:2"));
            Assert.IsTrue(before.Contains("表名:TLeaveRequestFlow,最小ID:1,最大ID:4,总行数:4"));

            Assert.IsTrue(target.Contains("表TLeaveRequest共计:总行数2,删减1行数据"));
            Assert.IsTrue(target.Contains("表TLeaveRequestItem共计:总行数2,删减1行数据"));
            Assert.IsTrue(target.Contains("表TLeaveRequestFlow共计:总行数4,删减2行数据"));

            Assert.IsTrue(after.Contains("表名:TLeaveRequest,最小ID:1,最大ID:1,总行数:1"));
            Assert.IsTrue(after.Contains("表名:TLeaveRequestItem,最小ID:1,最大ID:1,总行数:1"));
            Assert.IsTrue(after.Contains("表名:TLeaveRequestFlow,最小ID:1,最大ID:2,总行数:2"));
        }