Ejemplo n.º 1
0
        /// <summary>
        /// Compare two Thing entities
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void Compare(Thing expected, Thing actual)
        {
            // Check for nulls
            if (expected == null && actual == null)
            {
                return;
            }
            if (expected == null)
            {
                Assert.Fail("Expected null, got Thing");
            }
            if (actual == null)
            {
                Assert.Fail("Expected Thing, got null");
            }

            // Compare simple properties
            Assert.AreEqual(expected.Id, actual.Id, "Thing.Id not equal");
            Assert.AreEqual(expected.Name, actual.Name, "Thing.Name not equal");
            Assert.AreEqual(expected.Corners, actual.Corners, "Thing.Corners not equal");
            Assert.AreEqual(expected.Edges, actual.Edges, "Thing.Edges not equal");
            Assert.AreEqual(expected.Test, actual.Test, "Thing.Test not equal");

            // Compare WidgetList
            if (expected.WidgetListPopulated && actual.WidgetListPopulated)
            {
                WidgetComparer.Compare(expected.WidgetList, actual.WidgetList);
            }
        }
        /// <summary>
        /// Compare two FieldTest entities
        /// </summary>
        /// <param name="expected"></param>
        /// <param name="actual"></param>
        public static void Compare(FieldTest expected, FieldTest actual)
        {
            // Check for nulls
            if (expected == null && actual == null)
            {
                return;
            }
            if (expected == null)
            {
                Assert.Fail("Expected null, got FieldTest");
            }
            if (actual == null)
            {
                Assert.Fail("Expected FieldTest, got null");
            }

            // Compare simple properties
            Assert.AreEqual(expected.Id, actual.Id, "FieldTest.Id not equal");
            Assert.AreEqual(expected.IntField, actual.IntField, "FieldTest.IntField not equal");
            Assert.AreEqual(expected.IntFieldNullable, actual.IntFieldNullable, "FieldTest.IntFieldNullable not equal");
            Assert.AreEqual(expected.DecimalField, actual.DecimalField, "FieldTest.DecimalField not equal");
            Assert.AreEqual(expected.DecimalFieldNullable, actual.DecimalFieldNullable, "FieldTest.DecimalFieldNullable not equal");
            Assert.AreEqual(expected.StringField, actual.StringField, "FieldTest.StringField not equal");
            Assert.AreEqual(expected.StringFieldNullable, actual.StringFieldNullable, "FieldTest.StringFieldNullable not equal");
            Assert.AreEqual(expected.TextField, actual.TextField, "FieldTest.TextField not equal");
            Assert.AreEqual(expected.TextFieldNullable, actual.TextFieldNullable, "FieldTest.TextFieldNullable not equal");
            Compare(expected.DatetimeField, actual.DatetimeField, "FieldTest.DatetimeField");
            Compare(expected.DatetimeFieldNullable, actual.DatetimeFieldNullable, "FieldTest.DatetimeFieldNullable");
            Assert.AreEqual(expected.TinyintField, actual.TinyintField, "FieldTest.TinyintField not equal");
            Assert.AreEqual(expected.TinyintFieldNullable, actual.TinyintFieldNullable, "FieldTest.TinyintFieldNullable not equal");
            Compare(expected.TimestampField, actual.TimestampField, "FieldTest.TimestampField");
            Compare(expected.TimestampFieldNullable, actual.TimestampFieldNullable, "FieldTest.TimestampFieldNullable");
            Assert.AreEqual(expected.EnumField, actual.EnumField, "FieldTest.EnumField not equal");
            Assert.AreEqual(expected.EnumFieldNullable, actual.EnumFieldNullable, "FieldTest.EnumFieldNullable not equal");
            Assert.AreEqual(expected.ForeignKeyField, actual.ForeignKeyField, "FieldTest.ForeignKeyField not equal");
            Assert.AreEqual(expected.ForeignKeyFieldNullable, actual.ForeignKeyFieldNullable, "FieldTest.ForeignKeyFieldNullable not equal");
            Assert.AreEqual(DbConvert.ToDateInt(expected.IntDateField), DbConvert.ToDateInt(actual.IntDateField), "FieldTest.IntDateField not equal");
            Assert.AreEqual(DbConvert.ToDateInt(expected.IntDateFieldNullable), DbConvert.ToDateInt(actual.IntDateFieldNullable), "FieldTest.IntDateFieldNullable not equal");
            Assert.AreEqual(expected.IndexedField, actual.IndexedField, "FieldTest.IndexedField not equal");
            Assert.AreEqual(expected.IndexedFieldNullable, actual.IndexedFieldNullable, "FieldTest.IndexedFieldNullable not equal");
            Assert.AreEqual(expected.NodeIdField, actual.NodeIdField, "FieldTest.NodeIdField not equal");
            Assert.AreEqual(expected.NodeIdFieldNullable, actual.NodeIdFieldNullable, "FieldTest.NodeIdFieldNullable not equal");
            Assert.AreEqual(expected.DefaultValueIsTwo, actual.DefaultValueIsTwo, "FieldTest.DefaultValueIsTwo not equal");

            // Compare ForeignKeyFieldWidget
            if (expected.ForeignKeyFieldWidgetPopulated && actual.ForeignKeyFieldWidgetPopulated)
            {
                WidgetComparer.Compare(expected.ForeignKeyFieldWidget, actual.ForeignKeyFieldWidget);
            }

            // Compare ForeignKeyFieldNullableWidget
            if (expected.ForeignKeyFieldNullableWidgetPopulated && actual.ForeignKeyFieldNullableWidgetPopulated)
            {
                WidgetComparer.Compare(expected.ForeignKeyFieldNullableWidget, actual.ForeignKeyFieldNullableWidget);
            }
        }