public override void PerformTest() { for (int i = 0; i != input.Length; i++) { DerGeneralizedTime t = new DerGeneralizedTime(input[i]); if (output[i].IndexOf('G') > 0) // don't check local time the same way { if (!t.GetTime().Equals(output[i])) { Fail("failed conversion test"); } if (!t.ToDateTime().ToString(@"yyyyMMddHHmmss\Z").Equals(zOutput[i])) { Fail("failed date conversion test"); } } else { string offset = CalculateGmtOffset(t.ToDateTime()); if (!t.GetTime().Equals(output[i] + offset)) { Fail("failed conversion test"); } } } for (int i = 0; i != input.Length; i++) { DerGeneralizedTime t = new DerGeneralizedTime(input[i]); if (!t.ToDateTime().ToString(@"yyyyMMddHHmmss.fff\Z").Equals(mzOutput[i])) { Console.WriteLine("{0} != {1}", t.ToDateTime().ToString(@"yyyyMMddHHmmss.SSS\Z"), mzOutput[i]); Fail("failed long date conversion test"); } } }
public override void PerformTest() { for (int i = 0; i != input.Length; i++) { string ii = input[i], oi = output[i]; DerGeneralizedTime t = new DerGeneralizedTime(ii); DateTime dt = t.ToDateTime(); string st = t.GetTime(); if (oi.IndexOf('G') > 0) // don't check local time the same way { if (!st.Equals(oi)) { Fail("failed conversion test"); } string dts = dt.ToString(@"yyyyMMddHHmmss\Z"); string zi = zOutput[i]; if (!dts.Equals(zi)) { Fail("failed date conversion test"); } } else { string offset = CalculateGmtOffset(dt); if (!st.Equals(oi + offset)) { Fail("failed conversion test"); } } } for (int i = 0; i != input.Length; i++) { DerGeneralizedTime t = new DerGeneralizedTime(input[i]); if (!t.ToDateTime().ToString(@"yyyyMMddHHmmss.fff\Z").Equals(mzOutput[i])) { Console.WriteLine("{0} != {1}", t.ToDateTime().ToString(@"yyyyMMddHHmmss.SSS\Z"), mzOutput[i]); Fail("failed long date conversion test"); } } /* * [BMA-87] */ { DateTime t1 = new DerUtcTime("110616114855Z").ToDateTime(); DateTime t2 = new DerGeneralizedTime("20110616114855Z").ToDateTime(); if (t1 != t2) { Fail("failed UTC equivalence test"); } DateTime u1 = t1.ToUniversalTime(); DateTime u2 = t2.ToUniversalTime(); if (u1 != u2) { Fail("failed UTC conversion test"); } } }