Exemplo n.º 1
0
        public void GetReadData_CannotHandleNonNumericStrings_ThrowsException(string inputData)
        {
            // Arrange
            var cut = new CsvConverterDefaultShort();

            cut.Initialize(null, new DefaultTypeConverterFactory());

            // Act
            short actual = (short)cut.GetReadData(typeof(short), inputData, "Column1", 1, 1);

            // Assert
            Assert.Fail("Exception should be thrown when invalid values are passed into the parser!");
        }
Exemplo n.º 2
0
        public void GetReadData_CanConvertNullableShortsWithoutAnAttribute_ValuesConverted(string inputData, short?expected)
        {
            // Arrange
            var cut = new CsvConverterDefaultShort();

            cut.Initialize(null, new DefaultTypeConverterFactory());

            // Act
            short?actual = (short?)cut.GetReadData(typeof(short?), inputData, "Column1", 1, 1);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        [DataRow((short)20, "2,000%", "P0")]  // Differs between windows 10 (2,000%) & windows 7 (2,000 %)
        public void GetWriteData_CanConvertInt_IntConverted(short inputData, string expectedData, string formatData)
        {
            // Arrange
            var cut = new CsvConverterDefaultShort();

            cut.StringFormat = formatData;

            // Act
            string actualData = cut.GetWriteData(typeof(short), inputData, "Column1", 1, 1);

            // Windows 10 (2,000%) & Windows 7 (2,000 %) format percentages slightly differently
            // So remove spaces before comparing
            if (formatData != null && formatData.StartsWith("P"))
            {
                actualData = actualData.Replace(" ", "");
            }

            // Assert
            Assert.AreEqual(expectedData, actualData);
        }