Пример #1
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行"));
        }
Пример #2
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行"));
        }