Beispiel #1
0
        public void PopulateField_GivenDefinitionsAndNullOrEmptyValues_EnsuresCorrectType(FieldType fieldType, object cellValue)
        {
            //Arrange
            FieldDefinition fieldDefinition = new FieldDefinition
            {
                Name = "test-name",
                Type = fieldType
            };

            RowLoadResult rowLoadResult = new RowLoadResult
            {
                Fields = new Dictionary <string, object>()
            };

            ExcelRange excelRange = CreateExcelRange(cellValue);

            //Act
            ExcelDatasetReader.PopulateField(fieldDefinition, rowLoadResult, excelRange, true);

            //Assert
            rowLoadResult
            .Fields
            .Should()
            .HaveCount(1);

            rowLoadResult
            .Fields
            .First()
            .Value
            .Should()
            .BeNull();
        }
Beispiel #2
0
        public void AddtoDictionary_GivenTableDefinition_AddsHeaders()
        {
            //Arrange
            IDictionary <string, int> headers = new Dictionary <string, int>();

            string[] headerList = CreateHeaders().ToArray();

            TableDefinition tableDefinition = CreateTableDefinition();

            //Act
            for (int i = 0; i < headerList.Length; i++)
            {
                ExcelDatasetReader.AddToDictionary(headers, tableDefinition, headerList[i], i + 1);
            }

            //Assert
            headers
            .Count()
            .Should()
            .Be(headerList.Count());
        }