Ejemplo n.º 1
0
        public void ClrType_Basics()
        {
            var @object = new ClrType(typeof(object));
            var @string = new ClrType(typeof(string));
            var int32   = new ClrType(typeof(int));

            Assert.IsTrue(@object.IsAssignableTo(@object));
            Assert.IsTrue(@string.IsAssignableTo(@string));
            Assert.IsTrue(int32.IsAssignableTo(int32));

            Assert.IsTrue(@string.IsAssignableTo(@object));
            Assert.IsTrue(int32.IsAssignableTo(@object));

            Assert.IsFalse(int32.IsAssignableTo(@string));
            Assert.IsFalse(@string.IsAssignableTo(int32));

            Assert.IsFalse(@object.IsAssignableTo(int32));
            Assert.IsFalse(@object.IsAssignableTo(@string));

            Assert.IsTrue(int32.Equals(int32));
            Assert.IsTrue(int32.Equals((object)int32));
            Assert.IsFalse(int32.Equals(@string));
            Assert.IsFalse(int32.Equals((object)@string));
            Assert.IsFalse(@string.Equals(int32));

            Assert.AreEqual(int32.GetHashCode(), new ClrType(typeof(int)).GetHashCode());

            Assert.AreEqual("System.Object", @object.ToString());
            Assert.AreEqual("System.String", @string.ToString());
            Assert.AreEqual("System.Int32", int32.ToString());
        }
Ejemplo n.º 2
0
        public void ClrType_Void()
        {
            var int32 = new ClrType(typeof(int));

            Assert.IsTrue(ClrType.Void.IsAssignableTo(ClrType.Void));
            Assert.IsFalse(ClrType.Void.IsAssignableTo(int32));
            Assert.IsFalse(int32.IsAssignableTo(ClrType.Void)); // Counter-intuitive but true

            Assert.IsTrue(int32.Equals(int32));
            Assert.IsFalse(int32.Equals(42));
        }
Ejemplo n.º 3
0
        public void ClrType_CrossTypeSystemCheck()
        {
            var myType = new MyType();
            var int32  = new ClrType(typeof(int));

            Assert.ThrowsException <InvalidOperationException>(() => int32.IsAssignableTo(myType));
            Assert.ThrowsException <InvalidOperationException>(() => int32.Equals(myType));
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        public bool Equals(EdmType other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(ClrType.Equals(other.ClrType));
        }
Ejemplo n.º 5
0
        public bool Equals(TypeReference other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (Type == null && other.Type == null)
            {
                return(ClrType.Equals(other.ClrType) &&
                       Context.Equals(other.Context));
            }

            return(Type.Equals(other.Type));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determines whether two primary keys refer to the same entity.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override Boolean Equals(Object obj)
        {
            if ((Object)this == obj)
            {
                return(true);
            }
            var other = obj as EntityKey;

            if (other == null)
            {
                return(false);
            }
            if (!ClrType.Equals(other.ClrType))
            {
                return(false);
            }
            if (!Values.SequenceEqual(other.Values))
            {
                return(false);
            }
            return(true);
        }