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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void MapGetNullableChar() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.NullableCharProperty); 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); }
public void MapGetGuid() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.GuidProperty); var map = mapDefinition.CreateMap(); var guid = Guid.NewGuid(); var reader = SetupGetGuidFromReader("GuidProperty", guid); // Act var item = new TestModel(); map.LoadOrdinals(reader); map.Load(item, reader); // Assert Assert.Equal(guid, item.GuidProperty); }
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); }
public void SetStringParameterWithNull() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.StringProperty, true); var parameterName = "@StringProperty"; var command = CreateCommandWithParameter("MySproc", CommandType.StoredProcedure, parameterName); var map = mapDefinition.CreateMap(); // Act var item = new TestModel(); item.StringProperty = null; map.LoadParameters(command, item); // Assert Assert.Equal(DBNull.Value, command.Parameters[parameterName].Value); }
public void MapGetFloatWithDefaultToNullableField() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.NullableFloatProperty, true, (float)1.71); 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); }
public void MapGetByteWithDefaultToNullableField() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.NullableByteProperty, true, byte.MinValue); var map = mapDefinition.CreateMap(); var reader = SetupGetByteFromReader("NullableByteProperty", (byte)8); // Act var item = new TestModel(); map.LoadOrdinals(reader); map.Load(item, reader); // Assert Assert.NotNull(item.NullableByteProperty); Assert.Equal(8, item.NullableByteProperty.Value); }
public void MapGetDoubleWithDefaultToNullableField() { // Arrange var mapDefinition = new MapDefinition <TestModel>(); mapDefinition.Map(model => model.NullableDoubleProperty, true, 12.00001234); 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); }
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); }
public void AddNullableGuidParameter() { // Arrange var mapDefinition = new MapDefinition <TestModel>(false); mapDefinition.Map(model => model.NullableGuidProperty); var parameterName = "@NullableGuidProperty"; var command = new SqlCommand(); var map = mapDefinition.CreateMap(); // Act var item = new TestModel(); item.NullableGuidProperty = Guid.Empty; map.LoadParameters(command, item); // Assert Assert.Equal(Guid.Empty, command.Parameters[parameterName].Value); }
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); }
public void CreateMap() { // Arrange var mapDefinition = new MapDefinition <SampleModel>(); mapDefinition.Map(model => model.Test1, false); var dataRecord = Substitute.For <IDataRecord>(); dataRecord.GetOrdinal("Test1").Returns(1); dataRecord.GetString(1).Returns("DB Value"); // Act var map = mapDefinition.CreateMap(); map.LoadOrdinals(dataRecord); var item = new SampleModel(); map.Load(item, dataRecord); // Assert Assert.Equal("DB Value", item.Test1); }
public void AddDateTimeOffsetParameter() { // Arrange var mapDefinition = new MapDefinition <TestModel>(false); mapDefinition.Map(model => model.DateTimeOffsetProperty); var parameterName = "@DateTimeOffsetProperty"; var command = new SqlCommand(); var map = mapDefinition.CreateMap(); var now = DateTime.Today; // Act var item = new TestModel(); item.DateTimeOffsetProperty = now; map.LoadParameters(command, item); // Assert var parameter = (DateTimeOffset)command.Parameters[parameterName].Value; Assert.Equal(now.Month, parameter.Month); Assert.Equal(now.Day, parameter.Day); Assert.Equal(now.Year, parameter.Year); }
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); }
public void CreateMap() { // Arrange var mapDefinition = new MapDefinition<SampleModel>(); mapDefinition.Map(model => model.Test1, false); var dataRecord = Substitute.For<IDataRecord>(); dataRecord.GetOrdinal("Test1").Returns(1); dataRecord.GetString(1).Returns("DB Value"); // Act var map = mapDefinition.CreateMap(); map.LoadOrdinals(dataRecord); var item = new SampleModel(); map.Load(item, dataRecord); // Assert Assert.Equal("DB Value", item.Test1); }
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); }
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); }
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); }
public void SetStringParameterWithNull() { // Arrange var mapDefinition = new MapDefinition<TestModel>(); mapDefinition.Map(model => model.StringProperty, true); var parameterName = "@StringProperty"; var command = CreateCommandWithParameter("MySproc", CommandType.StoredProcedure, parameterName); var map = mapDefinition.CreateMap(); // Act var item = new TestModel(); item.StringProperty = null; map.LoadParameters(command, item); // Assert Assert.Equal(DBNull.Value, command.Parameters[parameterName].Value); }
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); }
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); }
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); }
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); }
public void AddNullableFloatParameterWithNull() { // Arrange var mapDefinition = new MapDefinition<TestModel>(false); mapDefinition.Map(model => model.NullableFloatProperty); var parameterName = "@NullableFloatProperty"; var command = new SqlCommand(); var map = mapDefinition.CreateMap(); // Act var item = new TestModel(); item.NullableFloatProperty = null; map.LoadParameters(command, item); // Assert Assert.Equal(DBNull.Value, command.Parameters[parameterName].Value); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void AddDateTimeOffsetParameter() { // Arrange var mapDefinition = new MapDefinition<TestModel>(false); mapDefinition.Map(model => model.DateTimeOffsetProperty); var parameterName = "@DateTimeOffsetProperty"; var command = new SqlCommand(); var map = mapDefinition.CreateMap(); var now = DateTime.Today; // Act var item = new TestModel(); item.DateTimeOffsetProperty = now; map.LoadParameters(command, item); // Assert var parameter = (DateTimeOffset)command.Parameters[parameterName].Value; Assert.Equal(now.Month, parameter.Month); Assert.Equal(now.Day, parameter.Day); Assert.Equal(now.Year, parameter.Year); }
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); }
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); }