示例#1
0
        public void NoKeyInterfaceAppliedTest()
        {
            var matcher = new IdentityConventionMatcher();

            var key = new Mock <IKey>();

            key.Setup(x => x.Properties).Returns(Array.Empty <IProperty>());

            var entity = new Mock <IEntityType>();

            entity.Setup(x => x.FindPrimaryKey()).Returns(key.Object);


            var results = matcher.GetMatchingElements(entity.Object).ToList();

            Assert.Empty(results);
        }
示例#2
0
        public void SingleKeyInterfaceAppliedTest()
        {
            var matcher = new IdentityConventionMatcher();

            var property = new Mock <IProperty>();

            property.Setup(x => x.ClrType).Returns(typeof(int?));

            var key = new Mock <IKey>();

            key.Setup(x => x.Properties).Returns(new[] { property.Object });

            var entity = new Mock <IEntityType>();

            entity.Setup(x => x.FindPrimaryKey()).Returns(key.Object);


            var results = matcher.GetMatchingElements(entity.Object).ToList();

            Assert.Single(results);
            Assert.Equal(typeof(IIdentity <int?>), results.Single().InterfaceType);
        }