private void AssertDateTimeParsing(DateTime?assertedDateTime, SifFormatter formatter, string test, String statement) { DateTime?parsedValue; parsedValue = formatter.ToDateTime(test); Console.WriteLine(statement); Console.WriteLine("parsing: " + test); Console.WriteLine("Asserted: {0} : {1}", assertedDateTime.Value, assertedDateTime.Value.ToFileTimeUtc()); Console.WriteLine("Parsed: {0} : {1}", parsedValue.Value, parsedValue.Value.ToFileTimeUtc()); Console.WriteLine(); AssertDateTime(statement, assertedDateTime, parsedValue); }
private void assertThrowsFormatException(SifFormatter formatter) { bool threwProperException = false; // Boolean try { formatter.ToBool("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("NumberFormatException was not thrown for toBoolean()", threwProperException); // DECIMAL threwProperException = false; try { formatter.ToDecimal("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for toDecimal()", threwProperException); // DATE threwProperException = false; try { formatter.ToDate("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for ToDate()", threwProperException); // // DateTime and Duration are not supported by the SIF1xFormatter // if (!(formatter is Sif1xFormatter)) { // DATETIME threwProperException = false; try { formatter.ToDateTime("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for ToDateTime()", threwProperException); // DURATION threwProperException = false; try { formatter.ToTimeSpan("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for toDuration()", threwProperException); } // INT threwProperException = false; try { formatter.ToInt("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for toint()", threwProperException); // TIME threwProperException = false; try { formatter.ToTime("asdf"); } catch (FormatException) { threwProperException = true; } Assertion.Assert("IllegalArgumentException was not thrown for toTime()", threwProperException); }