public void TestParse(String testFormat) { //HdDateTimeParser parser = new HdDateTimeParser(); String immutableFormat = String.Copy(testFormat); foreach (HdDateTime testValue in TestHdDateDates) { String source = testValue.ToString(testFormat); String immutableSource = String.Copy(source); HdDateTime parsedValue = HdDateTime.Parse(source, testFormat); if (testFormat.ToLower().Contains("ffffffff") && !testFormat.ToLower().Contains("fffffffff")) { Assert.IsTrue(testValue.EpochNanoseconds / 10 == parsedValue.EpochNanoseconds / 10, String.Format("{0} != {1}.", testValue.EpochNanoseconds, parsedValue.EpochNanoseconds)); } else if (testValue.TimestampModulo != 0) { Assert.IsTrue(testValue == parsedValue, String.Format("{0} != {1}.", testValue.EpochNanoseconds, parsedValue.EpochNanoseconds)); } else { Assert.IsTrue(testValue.DateTime == parsedValue.DateTime, String.Format("{0} != {1}.", testValue.EpochNanoseconds, parsedValue.EpochNanoseconds)); } Assert.IsTrue(immutableFormat == testFormat, "Format has been changed."); Assert.IsTrue(immutableSource == source, "Source has been changed."); } }
private void CheckParse(String from, String fmt, HdDateTime expected) { HdDateTime parsed = HdDateTime.Parse(from, fmt); if (!expected.Equals(parsed)) { // Comparison is here to avoid problems with Formatter affecting tests for Parser Assert.AreEqual(expected, parsed); Assert.AreEqual(expected.ToString(), parsed.ToString()); } Assert.AreEqual(expected.EpochNanoseconds, parsed.EpochNanoseconds); }