public void ThrowExceptionOnPropertyTypeHandlerMapperViaFieldThatIsNull()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>((Field)null, stringPropertyHandler);
        }
        public void ThrowExceptionOnPropertyTypeHandlerMapperViaExpressionThatIsNull()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(expression: null, propertyHandler: stringPropertyHandler);
        }
        public void ThrowExceptionOnPropertyTypeHandlerMapperViaFieldThatIsIsMissing()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(new Field("Whatever"), stringPropertyHandler);
        }
        public void ThrowExceptionOnPropertyTypeHandlerMapperViaExpressionThatIsAlreadyExisting()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var textPropertyHandler   = new TextPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.ColumnString, stringPropertyHandler);
            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, TextPropertyHandler>(e => e.ColumnString, textPropertyHandler);
        }
        public void ThrowExceptionOnPropertyTypeHandlerMapperViaPropertyNameThatIsAlreadyExisting()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var textPropertyHandler   = new TextPropertyHandler();
            var propertyName          = "ColumnString";

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(propertyName, stringPropertyHandler);
            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, TextPropertyHandler>(propertyName, textPropertyHandler);
        }
        public void ThrowExceptionOnPropertyTypeHandlerMapperViaFieldThatIsAlreadyExisting()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var textPropertyHandler   = new TextPropertyHandler();
            var field = new Field("ColumnString");

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(field, stringPropertyHandler);
            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, TextPropertyHandler>(field, textPropertyHandler);
        }
        public void TestPropertyHandlerMapperPropertyMappingViaExpression()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.ColumnString, stringPropertyHandler);

            // Act
            var actual   = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.ColumnString);
            var expected = stringPropertyHandler;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        public void TestPropertyHandlerCacheWithMapping()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyTypeHandlerCacheTestClass, StringPropertyHandler>(stringPropertyHandler);

            // Act
            var result   = PropertyHandlerCache.Get <PropertyTypeHandlerCacheTestClass, StringPropertyHandler>();
            var expected = stringPropertyHandler;

            // Assert
            Assert.AreEqual(expected, result);
        }
        public void TestPropertyHandlerMapperTypeMapping()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <string, StringPropertyHandler>(stringPropertyHandler);

            // Act
            var actual   = PropertyHandlerMapper.Get <string, StringPropertyHandler>();
            var expected = stringPropertyHandler;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #10
0
        public void TestPropertyHandlerMapperPropertyMappingViaPropertyName()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var propertyName          = "ColumnString";

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(propertyName, stringPropertyHandler);

            // Act
            var actual   = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(propertyName);
            var expected = stringPropertyHandler;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #11
0
        public void TestPropertyHandlerMapperPropertyMappingViaField()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var field = new Field("ColumnString");

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(field, stringPropertyHandler);

            // Act
            var actual   = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(field);
            var expected = stringPropertyHandler;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void TestPropertyHandlerMapperPropertyMappingViaExpressionOverride()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var textPropertyHandler   = new TextPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.ColumnString, stringPropertyHandler);
            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, TextPropertyHandler>(e => e.ColumnString, textPropertyHandler, true);

            // Act
            var actual   = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, object>(e => e.ColumnString);
            var expected = (actual is TextPropertyHandler);

            // Assert
            Assert.IsTrue(expected);
        }
Пример #13
0
        public void TestPropertyHandlerMapperPropertyMappingViaFieldOverride()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var textPropertyHandler   = new TextPropertyHandler();
            var field = new Field("ColumnString");

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(field, stringPropertyHandler);
            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, TextPropertyHandler>(field, textPropertyHandler, true);

            // Act
            var actual   = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, object>(field);
            var expected = (actual is TextPropertyHandler);

            // Assert
            Assert.IsTrue(expected);
        }
Пример #14
0
        public void TestPropertyHandlerMapperPropertyMappingViaExpressionWithPropertyHandlerAttribute()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.PropertyString, stringPropertyHandler);

            // Act
            var actual = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.PropertyString);

            // Assert
            Assert.IsNotNull(actual);

            // Act
            var textHandler = PropertyHandlerCache.Get <PropertyHandlerMapperTestClass, TextPropertyHandler>(e => e.PropertyString);

            // Assert
            Assert.IsNotNull(textHandler);
        }
Пример #15
0
        public void TestPropertyHandlerMapperPropertyMappingViaPropertyNameWithPropertyHandlerAttribute()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var propertyName          = "PropertyString";

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(propertyName, stringPropertyHandler);

            // Act
            var actual = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(propertyName);

            // Assert
            Assert.IsNotNull(actual);

            // Act
            var textHandler = PropertyHandlerCache.Get <PropertyHandlerMapperTestClass, TextPropertyHandler>(propertyName);

            // Assert
            Assert.IsNotNull(textHandler);
        }
Пример #16
0
        public void TestPropertyHandlerMapperPropertyMappingViaFieldWithPropertyHandlerAttribute()
        {
            // Setup
            var stringPropertyHandler = new StringPropertyHandler();
            var field = new Field("PropertyString");

            PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(field, stringPropertyHandler);

            // Act
            var actual = PropertyHandlerMapper.Get <PropertyHandlerMapperTestClass, StringPropertyHandler>(field);

            // Assert
            Assert.IsNotNull(actual);

            // Act
            var textHandler = PropertyHandlerCache.Get <PropertyHandlerMapperTestClass, TextPropertyHandler>(field);

            // Assert
            Assert.IsNotNull(textHandler);
        }
        public void TestPropertyHandlerImplicitForDateTimeKindAsNullAtomic()
        {
            // Setup
            PropertyHandlerMapper.Add(typeof(DateTime), new DateTimeToUtcKindHandler(), true);

            // Setup
            var models = CreateEntityModelForDateTimeKinds(10, true).AsList();

            using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
            {
                // Act
                models.ForEach(e => connection.Insert(e));

                // Act
                var result = connection.QueryAll <EntityModelForDateTimeKind>();

                // Assert
                models.ForEach(e =>
                {
                    var item = result.First(obj => obj.Id == e.Id);
                    Helper.AssertPropertiesEquality(e, item);
                });
            }
        }
        public void TestPropertyHandlerImplicitWithNumbersToLongHandlerAtomic()
        {
            // Setup
            PropertyHandlerMapper.Add(typeof(decimal), new DecimalToLongTypeHandler(), true);

            // Setup
            var models = CreateEntityModelForNumberPropertiesToLongTypes(10).AsList();

            using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
            {
                // Act
                models.ForEach(e => connection.Insert(e));

                // Act
                var result = connection.QueryAll <EntityModelForNumberPropertiesToLongType>();

                // Assert
                models.ForEach(e =>
                {
                    var item = result.First(obj => obj.Id == e.Id);
                    Helper.AssertPropertiesEquality(e, item);
                });
            }
        }
Пример #19
0
        public void TestPropertyHandlerForDateTimeKindForAnonymousTypes()
        {
            // Setup
            PropertyHandlerMapper.Add(typeof(DateTime), new DateTimeToUtcKindHandler(), true);

            // Setup
            var models = CreateEntityModelForDateTimeKindForAnonymousTypes(10).AsList();

            using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
            {
                // Act
                connection.InsertAll("[dbo].[PropertyHandler]", models);

                // Act
                var result = connection.QueryAll <EntityModelForDateTimeKind>();

                // Assert
                models.ForEach(e =>
                {
                    var item = result.First(obj => obj.Id == e.Id);
                    Helper.AssertPropertiesEquality(e, item);
                });
            }
        }
Пример #20
0
 public void ThrowExceptionOnPropertyTypeHandlerMapperViaExpressionWithNullPropertyHandler()
 {
     // Setup
     PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(e => e.ColumnString, null);
 }
Пример #21
0
 public void ThrowExceptionOnPropertyTypeHandlerMapperViaFieldWithNullPropertyHandler()
 {
     // Setup
     PropertyHandlerMapper.Add <PropertyHandlerMapperTestClass, StringPropertyHandler>(new Field("ColumnString"), null);
 }