public void returns_null_for_null_input()
        {
            //Arrange
            var reader = new DynamicDelimitedDataReader(_fields);

            //Act
            dynamic line = reader.ParseLine(null);

            //Assert
            Assert.Null(line);
        }
        public void throws_for_empty_input()
        {
            //Arrange
            var reader = new DynamicDelimitedDataReader(_fields);
            string fileData = "	";

            //Act
            var exception = Assert.Throws<ApplicationException>(() => reader.ParseLine(fileData));

            //Assert
            Assert.Contains("invalid field count", exception.Message, StringComparison.OrdinalIgnoreCase);
        }
コード例 #3
0
        public void returns_valid_dynamic_for_single_valid_input()
        {
            //Arrange
            var reader = new DynamicDelimitedDataReader(_fields);
            dynamic expected = InitializeDynamic(_fields, _values);

            //Act
            dynamic actual = reader.ParseLine(_values.JoinWithTabs());

            //Assert
            Assert.Equal(expected, actual);
        }
        public void returns_field_with_quotes_removed()
        {
            //Arrange
            var reader = new DynamicDelimitedDataReader(_fields);
            dynamic expected = InitializeDynamic(_fields, _values.Select(x => x.RemoveBoundingQuote()).ToArray());

            //Act
            dynamic actual = reader.ParseLine(_values.JoinWithTabs());

            //Assert
            // as IDictionary<string, object>
            var expectedValues = (expected as IDictionary<string, object>).Select(x => x.Value);
            var actualValues = (actual as IDictionary<string, object>).Select(x => x.Value);
            Assert.Equal(expectedValues, actualValues);
        }