Exemplo n.º 1
0
        public void NullComparisonEquivalence()
        {
            EdmEntityType entity = new EdmEntityType("Foo", "Bar", null, false, false);

            Assert.IsFalse(entity.IsEquivalentTo(null), "Type RHS");
            Assert.IsFalse(((IEdmEntityType)null).IsEquivalentTo(entity), "Type LHS");
            Assert.IsTrue(((IEdmEntityType)null).IsEquivalentTo(null), "Type Both");

            Assert.IsFalse(new EdmEntityTypeReference(entity, false).IsEquivalentTo(null), "TypeReference RHS");
            Assert.IsFalse(((IEdmEntityTypeReference)null).IsEquivalentTo(new EdmEntityTypeReference(entity, false)), "TypeReference LHS");
            Assert.IsTrue(((IEdmEntityTypeReference)null).IsEquivalentTo(null), "TypeReference Both");
        }
Exemplo n.º 2
0
        public void EqualityEntityTypeTest()
        {
            var baseEntityType = new EdmEntityType("NS", "Base", new EdmEntityType("NS", "BaseBase"), false, false);
            var differentBaseEntityType = new EdmEntityType("NS", "Base", new EdmEntityType("NS", "BaseBase"), true, false);

            var baseline = new EdmEntityType("NS", "Baseline", baseEntityType, false, false);
            baseline.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var match = new EdmEntityType("NS", "Baseline", baseEntityType, false, false);
            match.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentNamespace = new EdmEntityType("foo", "Baseline", baseEntityType, false, false);
            differentNamespace.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentName = new EdmEntityType("NS", "foo", baseEntityType, false, false);
            differentName.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentBaseType = new EdmEntityType("NS", "Baseline", differentBaseEntityType, false, false);
            differentBaseType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var nullBaseType = new EdmEntityType("NS", "Baseline", null, false, false);
            nullBaseType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentAbstract = new EdmEntityType("NS", "Baseline", baseEntityType, true, false);
            differentAbstract.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentIsOpen = new EdmEntityType("NS", "Baseline", baseEntityType, false, true);
            differentIsOpen.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));

            var differentProperties = new EdmEntityType("NS", "Baseline", baseEntityType, false, false);
            differentProperties.AddStructuralProperty("foo", EdmCoreModel.Instance.GetInt32(false));

            var differentKey = new EdmEntityType("NS", "Baseline", baseEntityType, false, false);
            var differentKeyId = differentProperties.AddStructuralProperty("id", EdmCoreModel.Instance.GetInt32(false));
            differentKey.AddKeys(differentKeyId);

            Assert.IsTrue(baseline.IsEquivalentTo(baseline), "Is the same.");
            Assert.IsFalse(baseline.IsEquivalentTo(match), "Is the same, different obj refs.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentNamespace), "Different namespace.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentName), "Different name.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentBaseType), "Different base type.");
            Assert.IsFalse(baseline.IsEquivalentTo(nullBaseType), "Null base type.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentAbstract), "Different abstract.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentIsOpen), "Different is open.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentProperties), "Different properties.");
            Assert.IsFalse(baseline.IsEquivalentTo(differentKey), "Different key.");
        }