public void Test2() { TransferRule aTr = MakeTransferRule(); ITableFilter theTarget = new TApplicationFilter.TApplicationFilter(); 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(2008, 10, 1), new DateTime(2008, 11, 1)); Console.WriteLine(target11); Console.WriteLine("进行还原"); string target12 = theTarget.RestoreTableData(new DateTime(2008, 10, 1), new DateTime(2008, 11, 1)); Console.WriteLine(target12); //全部数据还原没有任何数据改变 Assert.IsTrue(target12.Contains("表TApplication共计:增加0行,覆盖0行,删除0行")); Assert.IsTrue(target12.Contains("表TApplicationEmployee共计:增加0行,覆盖0行,删除0行")); Assert.IsTrue(target12.Contains("表TApplicationFlow共计:增加0行,覆盖0行,删除0行")); //第二次测试,分别模拟数据的增、删、改 Console.WriteLine("第二次测试"); MockChangment(); Console.WriteLine("筛选数据"); string target21 = theTarget.FilterTableData(new DateTime(2008, 10, 1), new DateTime(2008, 11, 1)); Console.WriteLine(target21); Console.WriteLine("进行还原"); string target22 = theTarget.RestoreTableData(new DateTime(2008, 10, 1), new DateTime(2008, 11, 1)); Console.WriteLine(target22); Assert.IsTrue(target22.Contains("表TApplication共计:增加1行,覆盖1行,删除1行")); Assert.IsTrue(target22.Contains("表TApplicationEmployee共计:增加0行,覆盖0行,删除1行")); Assert.IsTrue(target22.Contains("表TApplicationFlow共计:增加0行,覆盖0行,删除2行")); }
public void Test1() { //构建一个以TApplication为主的迁移策略,策略本身不会执行,仅仅是其中的一部分数据筛选功能进行测试 TransferRule aTr = MakeTransferRule(); ITableFilter theTarget = new TApplicationFilter.TApplicationFilter(); theTarget.ConfigTheFilter(aTr, _MainTableName, _RestoreDbName, _TempDbName, _RestoreDbName, _TempDbName); Assert.AreEqual(2, aTr.DbsToTransfer[0].ProtectTableNames.Count); string before = PrintAllTableInfo(aTr); Console.WriteLine("筛选之前的表信息"); Console.WriteLine(before); string target = theTarget.FilterTableData(new DateTime(2008, 10, 1), new DateTime(2008, 11, 1)); Console.WriteLine("进行筛选"); Console.WriteLine(target); string after = PrintAllTableInfo(aTr); Console.WriteLine(); Console.WriteLine("筛选之后的表信息"); Console.WriteLine(after); Assert.IsTrue(before.Contains("表名:TApplication,最小ID:9,最大ID:670,总行数:615")); Assert.IsTrue(before.Contains("表名:TApplicationEmployee,最小ID:8,最大ID:1363,总行数:842")); Assert.IsTrue(before.Contains("表名:TApplicationFlow,最小ID:1,最大ID:1297,总行数:1252")); Assert.IsTrue(target.Contains("表TApplication共计:总行数615,删减535行数据")); Assert.IsTrue(target.Contains("表TApplicationEmployee共计:总行数842,删减749行数据")); Assert.IsTrue(target.Contains("表TApplicationFlow共计:总行数1252,删减1086行数据")); Assert.IsTrue(after.Contains("表名:TApplication,最小ID:258,最大ID:342,总行数:80")); Assert.IsTrue(after.Contains("表名:TApplicationEmployee,最小ID:778,最大ID:891,总行数:93")); Assert.IsTrue(after.Contains("表名:TApplicationFlow,最小ID:463,最大ID:666,总行数:166")); }