コード例 #1
0
        /// <summary>
        /// Verify that the result of serializing and then deserializing
        /// an object is the same as the original.
        /// </summary>
        private void VerifyRoundtrip(Context context, LocalTime value)
        {
            // To be used in assert message
            string nameAsString = value.AsString();

            // Verify string serialization roundtrip
            string    stringValue       = value.AsString();
            LocalTime parsedStringValue = LocalTimeUtil.Parse(stringValue);

            context.Log.Assert(value == parsedStringValue, $"String roundtrip for {nameAsString} assert.");

            // Verify int serialization roundtrip
            int       intValue       = value.ToIsoInt();
            LocalTime parsedIntValue = LocalTimeUtil.FromIsoInt(intValue);

            context.Log.Assert(value == parsedIntValue, $"Int roundtrip for {nameAsString} assert.");
        }