public void Test2() { //备份 BackUpStatus bs = new BackUpStatus(); bs.AddStatusChangeObserver(new MockInfoObserver()); TransferService.BackUpData("测试筛选式数据迁移", new DateTime(2008, 12, 1), new DateTime(2009, 3, 1), bs); Thread.Sleep(30000); Console.WriteLine(string.Format("状态:{0} 下载文件地址:{1}", bs.Status, bs.SuccessFileName)); Console.WriteLine(string.Format("起始时间:{0} 结束时间:{1}", bs.StartTime, bs.EndTime)); Assert.AreEqual(bs.Status, Status.Success); Assert.IsFalse(string.IsNullOrEmpty(bs.SuccessFileName)); //清空待还原的数据库 DeleteAllTableData(_Db1); Assert.AreEqual(0, GetCountOfTable("TApplication", _Db1)); Assert.AreEqual(0, GetCountOfTable("TApplicationEmployee", _Db1)); Assert.AreEqual(0, GetCountOfTable("TApplicationFlow", _Db1)); Assert.AreEqual(0, GetCountOfTable("TEmployee", _Db1)); DeleteAllTableData(_Db2); Assert.AreEqual(0, GetCountOfTable("TCustomer", _Db2)); //还原 RestoreStatus rs = new RestoreStatus(); rs.AddStatusChangeObserver(new MockInfoObserver()); TransferService.RestoreData(bs.SuccessFullFileName, rs); Thread.Sleep(30000); Console.WriteLine(string.Format("状态:{0}", rs.Status)); Console.WriteLine(string.Format("起始时间:{0} 结束时间:{1}", rs.StartTime, rs.EndTime)); Assert.AreEqual(rs.Status, Status.Success); Assert.AreEqual(118, GetCountOfTable("TEmployee", _Db1)); Assert.AreEqual(1052, GetCountOfTable("TCustomer", _Db2)); Assert.AreEqual(169, GetCountOfTable("TApplication", _Db1)); Assert.AreEqual(227, GetCountOfTable("TApplicationEmployee", _Db1)); Assert.AreEqual(343, GetCountOfTable("TApplicationFlow", _Db1)); _MockITransferDataLog.PrintLogs(); _MockITransferDataLog.ClearLogs(); }
public void Test1() { //备份 BackUpStatus bs = new BackUpStatus(); bs.AddStatusChangeObserver(new MockInfoObserver()); TransferService.BackUpData("测试全覆盖式数据迁移", null, null, bs); Thread.Sleep(40000); Console.WriteLine(string.Format("状态:{0} 下载文件地址:{1}", bs.Status, bs.SuccessFileName)); Console.WriteLine(string.Format("起始时间:{0} 结束时间:{1}", bs.StartTime, bs.EndTime)); Assert.AreEqual(bs.Status, Status.Success); Assert.IsFalse(string.IsNullOrEmpty(bs.SuccessFileName)); //清空待还原的数据库 DeleteAllTableData(_Db1); DeleteAllTableData(_Db2); Assert.AreEqual(0, GetCountOfTable("TEmployee", _Db1)); Assert.AreEqual(0, GetCountOfTable("TCustomer", _Db2)); //还原数据 RestoreStatus rs = new RestoreStatus(); rs.AddStatusChangeObserver(new MockInfoObserver()); TransferService.RestoreData(bs.SuccessFullFileName, rs); Thread.Sleep(30000); Console.WriteLine(string.Format("状态:{0}", rs.Status)); Console.WriteLine(string.Format("起始时间:{0} 结束时间:{1}", rs.StartTime, rs.EndTime)); Assert.AreEqual(Status.Success, rs.Status); //测试数据是否还原成功 Assert.AreEqual(118, GetCountOfTable("TEmployee", _Db1)); Assert.AreEqual(1052, GetCountOfTable("TCustomer", _Db2)); _MockITransferDataLog.PrintLogs(); _MockITransferDataLog.ClearLogs(); }