コード例 #1
0
        public void ShouldMigrateOrganization()
        {
            //Arrange
            var oraOrgRows = new List <OracleOrganizationRow>
            {
                OracleOrganization.GenerateRowMock(1, "01"), // insert
                OracleOrganization.GenerateRowMock(2, "B1"), // update
                OracleOrganization.GenerateRowMock(9, "abc") // insert
            };

            var msOrgRows = new List <MsOrganizationRow>
            {
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "02", null), //ignored
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "B2", 2),    //update
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "xyz", 5),   //delete
            };

            MigrateData migration = new MigrateData(toDbType: DbTypesEnum.MsSql, DbStructure.OracleOrganizationTableName);

            migration.MsRows.UnionWith(msOrgRows);
            migration.OracleRows.UnionWith(oraOrgRows);

            //Act
            migration.Migrate();

            var newOracleOrgRows = migration.OracleRows;
            var newMsOrgRows     = migration.MsRows;

            //Assert
            Assert.AreEqual(4, newMsOrgRows.Count);
            Assert.AreEqual(oraOrgRows.Count, newOracleOrgRows.Count);

            var row = newMsOrgRows.Where(n => !n.OracleId.HasValue).ToList();

            Assert.IsTrue(row.Count == 1);

            row = newMsOrgRows.Where(n => n.OracleId.HasValue && n.OracleId.Value == 5).ToList();
            Assert.IsTrue(row.Count == 0);

            var rowOrg = newMsOrgRows.Single(n => n.OracleId.HasValue && n.OracleId.Value == 2) as MsOrganizationRow;

            Assert.AreEqual("B1", rowOrg.Code);

            rowOrg = newMsOrgRows.Single(n => n.OracleId.HasValue && n.OracleId.Value == 9) as MsOrganizationRow;
            Assert.AreEqual("abc", rowOrg.Code);

            rowOrg = newMsOrgRows.Single(n => n.OracleId.HasValue && n.OracleId.Value == 1) as MsOrganizationRow;
            Assert.AreEqual("01", rowOrg.Code);
        }
コード例 #2
0
        public void ShouldMigrateOrganization()
        {
            //Arrange
            var oraOrgRows = new List <OracleOrganizationRow>
            {
                OracleOrganization.GenerateRowMock(1, "01"), //delete - not implemented
                OracleOrganization.GenerateRowMock(2, "B1"), //upadate
                OracleOrganization.GenerateRowMock(9, "abc") //delete - not implemented
            };

            var msOrgRows = new List <MsOrganizationRow>
            {
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "02", null), //insert
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "B2", 2),    //update
                MsOrganization.GenerateRowMock(System.Guid.NewGuid(), "xyz", 5),   // ignore?
            };

            MigrateData migration = new MigrateData(toDbType: DbTypesEnum.Oracle, DbStructure.MsOrganizationTableName);

            migration.MsRows.UnionWith(msOrgRows);
            migration.OracleRows.UnionWith(oraOrgRows);

            //Act
            migration.Migrate();

            var newOracleOrgRows = migration.OracleRows;
            var newMsOrgRows     = migration.MsRows;

            //Assert
            Assert.AreEqual(5, newOracleOrgRows.Count);
            Assert.AreEqual(msOrgRows.Count, newMsOrgRows.Count);

            var rowOrg = newOracleOrgRows.Where(n => n.Id == 2).SingleOrDefault() as OracleOrganizationRow;

            Assert.AreEqual("B2", rowOrg.OrgCd);

            var rowOrgDel = newOracleOrgRows.Where(n => n.Id == 1 || n.Id == 9).Count();

            Assert.AreEqual(2, rowOrgDel);
        }