Exemple #1
0
        public void HasKey_should_throw_when_invalid_key_expression()
        {
            var entityConfiguration = new EntityTypeConfiguration<object>();

            Assert.Equal(
                Strings.InvalidPropertiesExpression("o => o.ToString()"),
                Assert.Throws<InvalidOperationException>(() => entityConfiguration.HasKey(o => o.ToString())).Message);
        }
Exemple #2
0
        public void HasKey_should_add_key_properties()
        {
            var mockEntityTypeConfiguration = new Mock<EntityTypeConfiguration>(typeof(Fixture));
            var entityConfiguration = new EntityTypeConfiguration<Fixture>(mockEntityTypeConfiguration.Object);

            entityConfiguration.HasKey(f => f.Id);

            mockEntityTypeConfiguration.Verify(e => e.Key(new[] { typeof(Fixture).GetProperty("Id") }));
        }