/// <summary> /// Verify that the result of serializing and then deserializing /// an object is the same as the original. /// </summary> private void VerifyRoundtrip(Context context, Instant value) { // To be used in assert message string nameAsString = value.AsString(); // Verify string serialization roundtrip string stringValue = value.AsString(); Instant parsedStringValue = InstantUtil.Parse(stringValue); context.Log.Assert(value == parsedStringValue, $"String roundtrip for {nameAsString} assert."); // Verify long serialization roundtrip long longValue = value.ToIsoLong(); Instant parsedLongValue = InstantUtil.FromIsoLong(longValue); context.Log.Assert(value == parsedLongValue, $"Long roundtrip for {nameAsString} assert."); }
public void Empty() { using (var context = new UnitTestContext(this)) { var empty = new Instant(); context.Log.Assert(empty == InstantUtil.Empty, "empty == InstantUtil.Empty"); context.Log.Assert(empty.HasValue() == false, "empty.HasValue() == false"); context.Log.Assert(empty.ToIsoString() == String.Empty, "empty.ToIsoString() == String.Empty"); context.Log.Assert(empty.AsString() == String.Empty, "empty.AsString() == String.Empty"); } }