예제 #1
0
        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);
        }
예제 #2
0
        public void Add_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.Add(propertyMap1);
            Assert.Same(propertyMap1, Assert.Single(mappings));
            Assert.Same(propertyMap1, mappings[0]);

            mappings.Add(propertyMap2);
            Assert.Equal(2, mappings.Count);
            Assert.Same(propertyMap2, mappings[1]);

            mappings.Add(propertyMap1);
            Assert.Equal(3, mappings.Count);
            Assert.Same(propertyMap1, mappings[2]);
        }
예제 #3
0
        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]);
        }
예제 #4
0
        public void Add_NullItem_ThrowsArgumentNullException()
        {
            ExcelPropertyMapCollection mappings = new TestClassMap().Properties;

            Assert.Throws <ArgumentNullException>("item", () => mappings.Add(null));
        }