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

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

            // Act
            byte actual = (byte)cut.GetReadData(typeof(byte), 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_CanConvertNullableBytesWithoutAnAttribute_ValuesConverted(string inputData, byte?expected)
        {
            // Arrange
            var cut = new CsvConverterDefaultByte();

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

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

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

            cut.StringFormat = formatData;

            // Act
            string actualData = cut.GetWriteData(typeof(byte), (byte)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);
        }