Esempio n. 1
0
        public void FromInt32Succeeds(int value)
        {
            var writer = new CborWriter();

            writer.WriteInt32(value);

            CoseHeaderValue headerValue = CoseHeaderValue.FromInt32(value);

            AssertExtensions.SequenceEqual(writer.Encode(), headerValue.EncodedValue.Span);
            Assert.Equal(value, headerValue.GetValueAsInt32());
        }
Esempio n. 2
0
        public void CoseHeaderValue_GetHashCode()
        {
            CoseHeaderValue value1         = default;
            CoseHeaderValue value2         = new CoseHeaderValue();
            int             value1HashCode = value1.GetHashCode();

            Assert.Equal(value1HashCode, value2.GetHashCode());

            value1 = CoseHeaderValue.FromInt32(0);
            value2 = CoseHeaderValue.FromInt32(0);
            Assert.Equal(value1.GetHashCode(), value2.GetHashCode());

            value1 = default;
            Assert.NotEqual(value1.GetHashCode(), value2.GetHashCode());

            value1 = new CoseHeaderValue();
            Assert.NotEqual(value1.GetHashCode(), value2.GetHashCode());
        }