public void Can_ignore_lower_or_equal_source_entity_type_using_entity_type_name()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);
            modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation);

            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));

            Assert.Null(model.FindEntityType(typeof(Customer).FullName));
            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));
            Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));

            Assert.NotNull(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Explicit));

            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));
            Assert.Null(model.FindEntityType(typeof(Customer).FullName));
        }
        public void Entity_returns_same_instance_for_entity_type_name()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);

            var entityBuilder = modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation);

            Assert.NotNull(entityBuilder);
            Assert.NotNull(model.FindEntityType(typeof(Customer).FullName));
            Assert.Same(entityBuilder, modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit));
        }
        public void Cannot_ignore_same_or_higher_source_entity_type_using_entity_clr_type()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);

            Assert.True(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation));
            Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.DataAnnotation));
            Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit));

            Assert.False(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation));

            Assert.NotNull(model.FindEntityType(typeof(Customer)));
        }
        public void Can_ignore_lower_source_entity_type_using_entity_clr_type()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);
            modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention);

            Assert.True(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation));

            Assert.Null(model.FindEntityType(typeof(Customer)));
            Assert.True(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation));
            Assert.Null(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Convention));
            Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.DataAnnotation));
        }
        public void Can_ignore_lower_source_entity_type_using_entity_type_name()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);
            modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation);

            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));

            Assert.Null(model.FindEntityType(typeof(Customer).FullName));
            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));
            Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));

            Assert.Equal(Strings.EntityIgnoredExplicitly(typeof(Customer).FullName),
                Assert.Throws<InvalidOperationException>(() =>
                    Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Explicit))).Message);
        }
        public void Can_ignore_existing_entity_type_using_entity_type_name_explicitly()
        {
            var model = new Model();
            var entityType = model.AddEntityType(typeof(Customer).FullName);
            var modelBuilder = CreateModelBuilder(model);

            Assert.Same(entityType, modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention).Metadata);
            Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));
            Assert.NotNull(model.FindEntityType(typeof(Customer).FullName));

            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));
            Assert.Null(model.FindEntityType(typeof(Customer).FullName));

            Assert.Equal(Strings.EntityIgnoredExplicitly(typeof(Customer).FullName),
                Assert.Throws<InvalidOperationException>(() =>
                    modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Explicit)).Message);
        }
        public void Cannot_ignore_higher_source_entity_type_using_entity_type_name()
        {
            var model = new Model();
            var modelBuilder = CreateModelBuilder(model);

            Assert.True(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Convention));
            Assert.Null(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention));
            Assert.NotNull(modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));

            Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Convention));

            Assert.NotNull(model.FindEntityType(typeof(Customer).FullName));
        }
        public void Can_ignore_existing_entity_type_using_entity_type_name()
        {
            var model = new Model();
            var entityType = model.AddEntityType(typeof(Customer).FullName);
            var modelBuilder = CreateModelBuilder(model);

            Assert.Same(entityType, modelBuilder.Entity(typeof(Customer).FullName, ConfigurationSource.Convention).Metadata);
            Assert.False(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.DataAnnotation));
            Assert.NotNull(model.FindEntityType(typeof(Customer).FullName));

            Assert.NotNull(modelBuilder.Ignore(typeof(Customer).FullName, ConfigurationSource.Explicit));

            Assert.Null(model.FindEntityType(typeof(Customer).FullName));
        }