public void MapObject_ClassMapFactory_ReturnsExpected() { var map = new TestClassMap(FallbackStrategy.ThrowIfPrimitive); ExcelClassMap <string> mapping = map.MapObject(t => t.Value); Assert.Empty(mapping.Properties); }
public void MapObject_ClassMapFactory_ReturnsExpected() { var map = new TestClassMap(FallbackStrategy.ThrowIfPrimitive); ObjectExcelPropertyMap <string> mapping = map.MapObject(t => t.Value); Assert.NotNull(mapping.ClassMap); }
public void Ctor_EmptyValueStrategy(FallbackStrategy emptyValueStrategy) { var map = new TestClassMap(emptyValueStrategy); Assert.Equal(emptyValueStrategy, map.EmptyValueStrategy); Assert.Equal(typeof(Helpers.TestClass), map.Type); }
public void Item_SetNull_ThrowsArgumentNullException() { MemberInfo propertyInfo = typeof(TestClass).GetProperty(nameof(TestClass.Property)); var map = new OneToOneMap <int>(new ColumnNameValueReader("Property")); var propertyMap = new ExcelPropertyMap(propertyInfo, map); ExcelPropertyMapCollection mappings = new TestClassMap().Properties; mappings.Add(propertyMap); Assert.Throws <ArgumentNullException>("item", () => mappings[0] = null); }
public void Item_SetValidItem_GetReturnsExpected() { MemberInfo propertyInfo = typeof(TestClass).GetProperty(nameof(TestClass.Property)); var map1 = new OneToOneMap <int>(new ColumnNameValueReader("Property")); var propertyMap1 = new ExcelPropertyMap(propertyInfo, map1); var map2 = new OneToOneMap <int>(new ColumnNameValueReader("Property")); var propertyMap2 = new ExcelPropertyMap(propertyInfo, map2); ExcelPropertyMapCollection mappings = new TestClassMap().Properties; mappings.Add(propertyMap1); mappings[0] = propertyMap2; Assert.Same(propertyMap2, mappings[0]); }
public void Insert_ValidItem_Success() { MemberInfo propertyInfo = typeof(TestClass).GetProperty(nameof(TestClass.Property)); var map1 = new OneToOneMap <int>(new ColumnNameValueReader("Property")); var propertyMap1 = new ExcelPropertyMap(propertyInfo, map1); var map2 = new OneToOneMap <int>(new ColumnNameValueReader("Property")); var propertyMap2 = new ExcelPropertyMap(propertyInfo, map2); ExcelPropertyMapCollection mappings = new TestClassMap().Properties; mappings.Insert(0, propertyMap1); Assert.Same(propertyMap1, Assert.Single(mappings)); Assert.Same(propertyMap1, mappings[0]); mappings.Insert(0, propertyMap2); Assert.Equal(2, mappings.Count); Assert.Same(propertyMap2, mappings[0]); mappings.Insert(1, propertyMap1); Assert.Equal(3, mappings.Count); Assert.Same(propertyMap1, mappings[1]); }
public void Insert_NullItem_ThrowsArgumentNullException() { ExcelPropertyMapCollection mappings = new TestClassMap().Properties; Assert.Throws <ArgumentNullException>("item", () => mappings.Insert(0, null)); }