Example #1
0
        public static void AssertRoundTrip(CBORObject o)
        {
            CBORObject o2 = FromBytesTestAB(CheckEncodeToBytes(o));

            TestCommon.CompareTestEqual(o, o2);
            TestNumber(o);
            TestCommon.AssertEqualsHashCode(o, o2);
        }
Example #2
0
        public static void TestStringEqualRoundTrip(EInteger obj)
        {
            string   str    = obj.ToString();
            EInteger newobj = EInteger.FromString(str);
            string   str2   = newobj.ToString();

            TestCommon.AssertEqualsHashCode(obj, newobj);
            TestCommon.AssertEqualsHashCode(str, str2);
        }
Example #3
0
        public static void AssertSer(CBORObject o, String s)
        {
            if (!s.Equals(o.ToString()))
            {
                Assert.AreEqual(s, o.ToString(), "o is not equal to s");
            }
            // Test round-tripping
            CBORObject o2 = FromBytesTestAB(o.EncodeToBytes());

            if (!s.Equals(o2.ToString()))
            {
                Assert.AreEqual(s, o2.ToString(), "o2 is not equal to s");
            }
            TestNumber(o);
            TestCommon.AssertEqualsHashCode(o, o2);
        }
Example #4
0
        public static void TestStringEqualRoundTrip(EInteger obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }
            string   str    = obj.ToString();
            EInteger newobj = EInteger.FromString(str);

            if (str.Length < 100 || !obj.Equals(newobj))
            {
                TestCommon.AssertEqualsHashCode(obj, newobj);
                string str2 = newobj.ToString();
                TestCommon.AssertEqualsHashCode(str, str2);
            }
        }
Example #5
0
        public static void AssertJSONSer(CBORObject o, String s)
        {
            if (!s.Equals(o.ToJSONString(), StringComparison.Ordinal))
            {
                Assert.AreEqual(s, o.ToJSONString(), "o is not equal to s");
            }
            // Test round-tripping
            CBORObject o2 = FromBytesTestAB(o.EncodeToBytes());

            if (!s.Equals(o2.ToJSONString(), StringComparison.Ordinal))
            {
                string msg = "o2 is not equal to s:\no = " +
                             TestCommon.ToByteArrayString(o.EncodeToBytes()) +
                             "\no2 = " + TestCommon.ToByteArrayString(o2.EncodeToBytes()) +
                             "\no2string = " + o2.ToString();
                Assert.AreEqual(s, o2.ToJSONString(), msg);
            }
            TestNumber(o);
            TestCommon.AssertEqualsHashCode(o, o2);
        }