public static void TryDecode_Invalid()
        {
            ReadOnlyMemory <byte> inputData = TimestampTokenTestData.Symantec1.TokenInfoBytes;

            Assert.False(
                Rfc3161TimestampTokenInfo.TryDecode(
                    inputData.Slice(0, inputData.Length - 1),
                    out Rfc3161TimestampTokenInfo tokenInfo,
                    out int bytesRead));

            Assert.Equal(0, bytesRead);
            Assert.Null(tokenInfo);
        }
        private static void VerifyAttributesAreEqual(AsnEncodedData actual, AsnEncodedData expected)
        {
            Assert.NotSame(expected.Oid, actual.Oid);
            Assert.Equal(expected.Oid.Value, actual.Oid.Value);

            // We need to decode bytes because DER and BER may encode the same information slightly differently
            Rfc3161TimestampTokenInfo expectedToken;

            Assert.True(Rfc3161TimestampTokenInfo.TryDecode(expected.RawData, out expectedToken, out _));

            Rfc3161TimestampTokenInfo actualToken;

            Assert.True(Rfc3161TimestampTokenInfo.TryDecode(actual.RawData, out actualToken, out _));

            Assert.Equal(expectedToken.GetSerialNumber().ByteArrayToHex(), actualToken.GetSerialNumber().ByteArrayToHex());
            Assert.Equal(expectedToken.Timestamp, actualToken.Timestamp);
            Assert.Equal(expectedToken.HashAlgorithmId.Value, Oids.Sha256);
            Assert.Equal(expectedToken.HashAlgorithmId.Value, actualToken.HashAlgorithmId.Value);
        }
        private static void ValidateTokenInfo(
            ReadOnlyMemory <byte> tokenInfoBytes,
            TimestampTokenTestData testData,
            int?lengthFromTry)
        {
            Rfc3161TimestampTokenInfo tokenInfo;

            Assert.True(
                Rfc3161TimestampTokenInfo.TryDecode(tokenInfoBytes, out tokenInfo, out int bytesRead),
                "Rfc3161TimestampTokenInfo.TryDecode");

            Assert.NotNull(tokenInfo);

            if (lengthFromTry != null)
            {
                Assert.Equal(lengthFromTry.Value, bytesRead);
            }

            AssertEqual(testData, tokenInfo);
        }