Пример #1
0
        public void DefaultValueDoesNotSupportDecimal()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            // Act, Assert
            Assert.Throws <InvalidOperationException>(
                () => mapDefinition.Map(model => model.DecimalProperty, true, (decimal)3.14));
        }
Пример #2
0
        public void DefaultValueNotSetWithAllowNullsFails()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            // Act, Assert
            Assert.Throws <InvalidOperationException>(
                () => mapDefinition.Map(model => model.StringProperty, false, "default"));
        }
Пример #3
0
        public void DefaultValueIncompatibleTypesFail()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            // Act, Assert
            Assert.Throws <ArgumentException>(
                () => mapDefinition.Map(model => model.StringProperty, true, 5));
        }
Пример #4
0
        public void TryToMapInvalidFails()
        {
            // Arrange
            var mapDefinition = new MapDefinition <InvalidModel>();

            // Act, Assert
            Assert.Throws <ArgumentOutOfRangeException>(
                () => mapDefinition.Map(model => model.Data));
        }
Пример #5
0
        public void TryToMapMethodFails()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act, Assert
            Assert.Throws <InvalidOperationException>(
                () => mapDefinition.Map(model => model.TestMethod("Test"), false));
        }
Пример #6
0
        public void MapTypeThenOverride()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.MapType();
            mapDefinition.Map(model => model.Test2, "Foo", true);
            mapDefinition.Map(model => model.Test3, false);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            Assert.Equal(3, fields.Count);
            AssertFieldMap(fields, "Test1", "Test1", true);
            AssertFieldMap(fields, "Test2", "Foo", true);
            AssertFieldMap(fields, "Test3", "Test3", false);
        }
Пример #7
0
        public void DefaultValueDoesNotSupportGuid()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            // Act, Assert
            Assert.Throws <InvalidOperationException>(
                () => mapDefinition.Map(model => model.GuidProperty, true, Guid.NewGuid()));
        }
Пример #8
0
        public void DefaultValueDoesNotSupportDateTime()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            // Act, Assert
            Assert.Throws <InvalidOperationException>(
                () => mapDefinition.Map(model => model.DateTimeProperty, true, DateTime.Today));
        }
Пример #9
0
        public void MapPropertySetSourceColumnAndAllowNulls()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test3, "Source", true);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test3", "Source", true);
        }
Пример #10
0
        public void MapPropertySetSourceColumn()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test2, "Bar");

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test2", "Bar", false);
        }
Пример #11
0
        public void MapPropertySetAllowNullsWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1, true, "default");

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test1", "Test1", true, "default");
        }
Пример #12
0
        public void MapProperty()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test1", "Test1", true);
        }
Пример #13
0
        public void MapPropertySetAllowNulls()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1, false);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test1", "Test1", false);
        }
Пример #14
0
        public void MapPropertySetSourceColumnAndAllowNulls()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test3, "Source", true);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test3", "Source", true);
        }
Пример #15
0
        public void MapPropertyExplicit()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test3, "Explicit", true, int.MaxValue);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test3", "Explicit", true, int.MaxValue);
        }
Пример #16
0
        public void MapPropertySetSourceColumn()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test2, "Bar");

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test2", "Bar", false);
        }
Пример #17
0
        public void MapPropertySetAllowNullsWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1, true, "default");

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test1", "Test1", true, "default");
        }
Пример #18
0
        public void MapPropertySetAllowNulls()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1, false);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test1", "Test1", false);
        }
Пример #19
0
        public void MapProperty()
        {
            // Arrange
            var mapDefinition = new MapDefinition <SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test1);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;

            AssertFieldMap(fields, "Test1", "Test1", true);
        }
Пример #20
0
        public void MapGetByte()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.ByteProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetByteFromReader("ByteProperty", (byte)8);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(8, item.ByteProperty);
        }
Пример #21
0
        public void MapGetInt()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.IntProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetIntFromReader("IntProperty", 32);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(32, item.IntProperty);
        }
Пример #22
0
        public void MapGetShort()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.ShortProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetShortFromReader("ShortProperty", (short)16);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(16, item.ShortProperty);
        }
Пример #23
0
        public void AddDateTimeParameter()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>(false);
            mapDefinition.Map(model => model.DateTimeProperty);
            var parameterName = "@DateTimeProperty";
            var command = new SqlCommand();
            var map = mapDefinition.CreateMap();

            // Act
            var item = new TestModel();
            item.DateTimeProperty = DateTime.Today;
            map.LoadParameters(command, item);

            // Assert
            Assert.Equal(DateTime.Today, command.Parameters[parameterName].Value);
        }
Пример #24
0
        public void SetNullableIntParameter()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableIntProperty);
            var parameterName = "@NullableIntProperty";
            var command = CreateCommandWithParameter("MySproc", CommandType.StoredProcedure, parameterName);
            var map = mapDefinition.CreateMap();

            // Act
            var item = new TestModel();
            item.NullableIntProperty = 32;
            map.LoadParameters(command, item);

            // Assert
            Assert.Equal(32, command.Parameters[parameterName].Value);
        }
Пример #25
0
        public void MapGetDoubleWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.DoubleProperty, true, 6.022140857);
            var map    = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("DoubleProperty");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(6.022140857, item.DoubleProperty);
        }
Пример #26
0
        public void MapGetBoolWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.BoolProperty, true, false);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetBoolFromReader("BoolProperty", true);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(true, item.BoolProperty);
        }
Пример #27
0
        public void MapGetStringWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.StringProperty, true, "default");
            var map    = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("StringProperty");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal("default", item.StringProperty);
        }
Пример #28
0
        public void MapGetFloatWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.FloatProperty, true, (float)3.14);
            var map    = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("FloatProperty");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((float)3.14, item.FloatProperty);
        }
Пример #29
0
        public void MapGetInt()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.IntProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetIntFromReader("IntProperty", 32);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(32, item.IntProperty);
        }
Пример #30
0
        public void MapGetIntWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.IntProperty, true, int.MaxValue);
            var map    = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("IntProperty");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(int.MaxValue, item.IntProperty);
        }
Пример #31
0
        public void MapGetShort()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.ShortProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetShortFromReader("ShortProperty", (short)16);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(16, item.ShortProperty);
        }
Пример #32
0
        public void MapGetNullableGuidWithNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.NullableGuidProperty);
            var map    = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("NullableGuidProperty");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Null(item.NullableGuidProperty);
        }
Пример #33
0
        public void MapGetByte()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.ByteProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetByteFromReader("ByteProperty", (byte)8);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(8, item.ByteProperty);
        }
Пример #34
0
        public void MapGetLongWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.LongProperty, true, long.MinValue);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetLongFromReader("LongProperty", 64);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(64, item.LongProperty);
        }
Пример #35
0
        public void MapGetDouble()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.DoubleProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetDoubleFromReader("DoubleProperty", 6.022140857);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(6.022140857, item.DoubleProperty);
        }
Пример #36
0
        public void MapGetFloat()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.FloatProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetFloatFromReader("FloatProperty", (float)3.141);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((float)3.141, item.FloatProperty);
        }
Пример #37
0
        public void MapGetDecimal()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.DecimalProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetDecimalFromReader("DecimalProperty", (decimal)3.141529);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((decimal)3.141529, item.DecimalProperty);
        }
Пример #38
0
        public void MapGetDateTime()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.DateTimeProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetDateTimeFromReader("DateTimeProperty", DateTime.Today);

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(DateTime.Today, item.DateTimeProperty);
        }
Пример #39
0
        public void MapGetCharWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.CharProperty, true, 'e');
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetCharFromReader("CharProperty", 'c');

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal('c', item.CharProperty);
        }
Пример #40
0
        public void MapGetNullableString()
        {
            // Arrange
            var mapDefinition = new MapDefinition <TestModel>();

            mapDefinition.Map(model => model.StringProperty);
            var map    = mapDefinition.CreateMap();
            var reader = SetupGetStringFromReader("StringProperty", "This is a test.");

            // Act
            var item = new TestModel();

            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal("This is a test.", item.StringProperty);
        }
Пример #41
0
        public void MapGetFloatWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.FloatProperty, true, (float)3.14);
            var map = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("FloatProperty");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((float)3.14, item.FloatProperty);
        }
Пример #42
0
        public void MapGetIntWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.IntProperty, true, int.MaxValue);
            var map = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("IntProperty");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(int.MaxValue, item.IntProperty);
        }
Пример #43
0
        public void MapGetStringWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.StringProperty, true, "default");
            var map = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("StringProperty");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal("default", item.StringProperty);
        }
Пример #44
0
        public void MapGetNullableGuidWithNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableGuidProperty);
            var map = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("NullableGuidProperty");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Null(item.NullableGuidProperty);
        }
Пример #45
0
        public void MapPropertyExplicit()
        {
            // Arrange
            var mapDefinition = new MapDefinition<SampleModel>();

            // Act
            mapDefinition.Map(model => model.Test3, "Explicit", true, int.MaxValue);

            // Assert
            var fields = mapDefinition.FieldMapDefinitions;
            AssertFieldMap(fields, "Test3", "Explicit", true, int.MaxValue);
        }
Пример #46
0
        public void MapGetShortWithDefaultToNullableField()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableShortProperty, true, short.MinValue);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetShortFromReader("NullableShortProperty", (short)16);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.NotNull(item.NullableShortProperty);
            Assert.Equal(16, item.NullableShortProperty.Value);
        }
Пример #47
0
        public void MapGetDoubleWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.DoubleProperty, true, 12.00001234);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetDoubleFromReader("DoubleProperty", 6.022140857);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(6.022140857, item.DoubleProperty);
        }
Пример #48
0
        public void MapGetNullableFloat()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableFloatProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetFloatFromReader("NullableFloatProperty", (float)3.141);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.NotNull(item.NullableFloatProperty);
            Assert.Equal((float)3.141, item.NullableFloatProperty.Value);
        }
Пример #49
0
        public void MapGetNullableDouble()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableDoubleProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetDoubleFromReader("NullableDoubleProperty", 6.022140857);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.NotNull(item.NullableDoubleProperty);
            Assert.Equal(6.022140857, item.NullableDoubleProperty.Value);
        }
Пример #50
0
        public void MapGetChar()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.CharProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetCharFromReader("CharProperty", 'c');

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal('c', item.CharProperty);
        }
Пример #51
0
        public void MapGetNullableDateTimeOffset()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableDateTimeOffsetProperty);
            var map = (ISqlMap<TestModel>)mapDefinition.CreateMap();
            var reader = SetupGetDateTimeOffsetFromReader("NullableDateTimeOffsetProperty", DateTime.Today);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);
            map.LoadSqlDataReader(item, reader);

            // Assert
            Assert.NotNull(item.NullableDateTimeOffsetProperty);
            Assert.Equal(DateTime.Today, item.NullableDateTimeOffsetProperty.Value);
        }
Пример #52
0
        public void MapGetNullableString()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.StringProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetStringFromReader("StringProperty", "This is a test.");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal("This is a test.", item.StringProperty);
        }
Пример #53
0
        public void MapGetDecimal()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.DecimalProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetDecimalFromReader("DecimalProperty", (decimal)3.141529);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((decimal)3.141529, item.DecimalProperty);
        }
Пример #54
0
        public void MapGetDateTime()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.DateTimeProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetDateTimeFromReader("DateTimeProperty", DateTime.Today);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(DateTime.Today, item.DateTimeProperty);
        }
Пример #55
0
        public void MapGetDoubleWithDefaultNull()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.DoubleProperty, true, 6.022140857);
            var map = mapDefinition.CreateMap();
            var reader = GetDataRecordWithNullColumn("DoubleProperty");

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(6.022140857, item.DoubleProperty);
        }
Пример #56
0
        public void MapGetNullableGuid()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableGuidProperty);
            var map = mapDefinition.CreateMap();
            var guid = Guid.NewGuid();
            var reader = SetupGetGuidFromReader("NullableGuidProperty", guid);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.NotNull(item.NullableGuidProperty);
            Assert.Equal(guid, item.NullableGuidProperty.Value);
        }
Пример #57
0
        public void MapGetLong()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.LongProperty);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetLongFromReader("LongProperty", 64);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(64, item.LongProperty);
        }
Пример #58
0
        public void MapGetBoolWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.BoolProperty, true, false);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetBoolFromReader("BoolProperty", true);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal(true, item.BoolProperty);
        }
Пример #59
0
        public void MapGetCharWithDefaultToNullableField()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.NullableCharProperty, true, 'e');
            var map = mapDefinition.CreateMap();
            var reader = SetupGetCharFromReader("NullableCharProperty", 'c');

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.NotNull(item.NullableCharProperty);
            Assert.Equal('c', item.NullableCharProperty.Value);
        }
Пример #60
0
        public void MapGetFloatWithDefault()
        {
            // Arrange
            var mapDefinition = new MapDefinition<TestModel>();
            mapDefinition.Map(model => model.FloatProperty, true, (float)1.71);
            var map = mapDefinition.CreateMap();
            var reader = SetupGetFloatFromReader("FloatProperty", (float)3.141);

            // Act
            var item = new TestModel();
            map.LoadOrdinals(reader);
            map.Load(item, reader);

            // Assert
            Assert.Equal((float)3.141, item.FloatProperty);
        }