示例#1
0
        /// <summary>
        /// Create the org table when all that exists already is Employee
        /// </summary>
        protected void CreateOrgTableBase()
        {
            var provider      = GetIntProvider();
            var engine        = new ModelMerge <int>(provider, new Type[] { typeof(EmployeeInt), typeof(Organization) });
            var schemaTables  = new TableInfo[] { new TableInfo("dbo", "Employee") };
            var schemaColumns = Enumerable.Empty <ColumnInfo>();
            var actions       = engine.Compare(schemaTables, schemaColumns);

            Assert.IsTrue(
                actions.Count() == 1 &&
                actions.All(a => provider.GetTableInfo((a as CreateTable).ModelType).Equals(new TableInfo("dbo", "Organization"))));
        }
示例#2
0
        protected void CreateTwoTablesBase()
        {
            var provider      = GetIntProvider();
            var engine        = new ModelMerge <int>(provider, new Type[] { typeof(EmployeeInt), typeof(Organization) });
            var schemaTables  = Enumerable.Empty <TableInfo>();
            var schemaColumns = Enumerable.Empty <ColumnInfo>();
            var actions       = engine.Compare(schemaTables, schemaColumns);

            Assert.IsTrue(actions.Any(a => (a as CreateTable)?.ModelType.Equals(typeof(EmployeeInt)) ?? false), "Employee table not created");
            Assert.IsTrue(actions.Any(a => (a as CreateTable)?.ModelType.Equals(typeof(Organization)) ?? false), "Organization table not created.");
            Assert.IsTrue(actions.Any(a => (a as AddForeignKey)?.ForeignKeyInfo.Parent.Equals(new ColumnInfo("dbo", "Organization", "Id")) ?? false), "Foreign key not created");
        }
示例#3
0
        public void TestTestModelToOnce()
        {
            // Arrange
            var testModel = CreateLoadedTestModel();
            var onceModel = new OnceModel {
                String = "Came From Behind"
            };

            // Act
            ModelMerge.MergeProperties(testModel, onceModel, MergeMode.All);

            // Assert
            Assert.IsTrue(testModel.String.Equals(onceModel.String));
        }
示例#4
0
        public void TestModelMergeAll()
        {
            // Arrange
            TestModel newValuesModel, model;

            InitializeModelsForMerge(out newValuesModel, out model);

            // Act
            ModelMerge.MergeProperties(model, newValuesModel);

            // Assert
            Assert.IsTrue(newValuesModel.Integer.Equals(model.Integer));
            Assert.IsTrue(newValuesModel.Decimal.Equals(model.Decimal));
            Assert.IsTrue(newValuesModel.Float.Equals(model.Float));
            Assert.IsTrue(newValuesModel.String.Equals(model.String));
            Assert.IsTrue(newValuesModel.Object.Equals(model.Object));
        }
示例#5
0
        public void TestModelMergeOnce()
        {
            // Arrange
            var firstValue  = "Hello";
            var secondValue = "World";

            var model = new OnceModel {
                String = null
            };
            var newValues1 = new OnceModel {
                String = firstValue
            };
            var newValues2 = new OnceModel {
                String = secondValue
            };

            // Act
            ModelMerge.MergeProperties(model, newValues1, MergeMode.Update);
            ModelMerge.MergeProperties(model, newValues2, MergeMode.Update);

            // Assert
            Assert.IsTrue(model.String.Equals(newValues1.String));
        }