Exemple #1
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]);
        }
Exemple #2
0
        public void Insert_NullItem_ThrowsArgumentNullException()
        {
            ExcelPropertyMapCollection mappings = new TestClassMap().Properties;

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