コード例 #1
0
ファイル: ParseTag.cs プロジェクト: zerodev1200/corefxlab
        public static void TestEquals()
        {
            Asn1Tag integer             = new Asn1Tag(TagClass.Universal, 2);
            Asn1Tag integerAgain        = new Asn1Tag(TagClass.Universal, 2);
            Asn1Tag context2            = new Asn1Tag(TagClass.ContextSpecific, 2);
            Asn1Tag constructedContext2 = new Asn1Tag(TagClass.ContextSpecific, 2, true);
            Asn1Tag application2        = new Asn1Tag(TagClass.Application, 2);

            Assert.False(integer.Equals(null));
            Assert.False(integer.Equals(0x02));
            Assert.False(integer.Equals(context2));
            Assert.False(context2.Equals(constructedContext2));
            Assert.False(context2.Equals(application2));

            Assert.Equal(integer, integerAgain);
            Assert.True(integer == integerAgain);
            Assert.True(integer != context2);
            Assert.False(integer == context2);
            Assert.False(context2 == constructedContext2);
            Assert.False(context2 == application2);

            Assert.NotEqual(integer.GetHashCode(), context2.GetHashCode());
            Assert.NotEqual(context2.GetHashCode(), constructedContext2.GetHashCode());
            Assert.NotEqual(context2.GetHashCode(), application2.GetHashCode());
            Assert.Equal(integer.GetHashCode(), integerAgain.GetHashCode());
        }