Exemple #1
0
        public void Should_not_set_both_column_index_and_name()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action1 = () =>
            {
                excelTableColumnAttribute.ColumnIndex = 100;
                excelTableColumnAttribute.ColumnName  = "TEST";
            };

            Action action2 = () =>
            {
                excelTableColumnAttribute.ColumnName  = "TEST";
                excelTableColumnAttribute.ColumnIndex = 100;
            };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action1.Should().Throw <InvalidOperationException>().WithMessage($"Cannot set both {nameof(excelTableColumnAttribute.ColumnName)} and {nameof(excelTableColumnAttribute.ColumnIndex)}!");
            action2.Should().Throw <InvalidOperationException>().WithMessage($"Cannot set both {nameof(excelTableColumnAttribute.ColumnName)} and {nameof(excelTableColumnAttribute.ColumnIndex)}!");
        }
        public void Tets_MappingUnambiguity()
        {
            try
            {
                var a = new ExcelTableColumnAttribute();
                a.ColumnIndex = 100;
                a.ColumnName  = "TEST";
                Assert.Fail("Should get an exception");
            }
            catch (ArgumentException)
            {
                return;
            }

            Assert.Fail("Should get an ArgumentException");
        }
        public void Tets_MappingName()
        {
            try
            {
                var a = new ExcelTableColumnAttribute();
                a.ColumnName = "   ";

                Assert.Fail("Should get an exception");
            }
            catch (ArgumentException)
            {
                return;
            }

            Assert.Fail("Should get an ArgumentException");
        }
Exemple #4
0
        public void Test_MappingName()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => { excelTableColumnAttribute.ColumnName = "   "; };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.Should().Throw <ArgumentException>();
        }
        public void Test_MappingIndexBase()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => { excelTableColumnAttribute.ColumnIndex = 0; };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldThrow <ArgumentException>();
        }
Exemple #6
0
        public void Should_column_name_cannot_be_null_or_empty()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action1 = () => { excelTableColumnAttribute.ColumnName = "   "; };
            Action action2 = () => { excelTableColumnAttribute.ColumnName = null; };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action1.Should().Throw <ArgumentException>().WithMessage("Value must not be empty*");
            action2.Should().Throw <ArgumentNullException>().WithMessage("Value cannot be null*");
        }
Exemple #7
0
        public void Should_column_index_cannot_be_equal_or_less_than_zero()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action1 = () => { excelTableColumnAttribute.ColumnIndex = 0; };
            Action action2 = () => { excelTableColumnAttribute.ColumnIndex = -10; };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action1.Should().Throw <InvalidOperationException>().WithMessage($"{nameof(excelTableColumnAttribute.ColumnIndex)} cannot be zero or negative!");
            action2.Should().Throw <InvalidOperationException>().WithMessage($"{nameof(excelTableColumnAttribute.ColumnIndex)} cannot be zero or negative!");
        }
        public void Test_MappingUnambiguity()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var excelTableColumnAttribute = new ExcelTableColumnAttribute();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () =>
            {
                excelTableColumnAttribute.ColumnIndex = 100;
                excelTableColumnAttribute.ColumnName  = "TEST";
            };

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldThrow <ArgumentException>();
        }
 public ExcelTableColumnAttributeAndPropertyInfo(PropertyInfo propertyInfo, ExcelTableColumnAttribute columnAttribute)
 {
     PropertyInfo    = propertyInfo;
     ColumnAttribute = columnAttribute;
 }