test/Shared/UnitTests/Core/Common/Internal/Materialization/CodeGenEmitterTests.cs
/// <summary>
/// Not really a unit test because of the complexity of setting up everything the materializer needs.
/// </summary>
Not really a unit test because of the complexity of setting up everything the materializer needs.
Not really a unit test because of the complexity of setting up everything the materializer needs .
[Fact]
        public void Materialized_entities_have_override_Equals_flag_set_appropriately()
        {
            using (var context = new EntityTypesContext())
            {
                var stateManager = ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager;
                var wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.IPocos.First())).WrappedEntity;
                Assert.IsType<LightweightEntityWrapper<IPocoEntity>>(wrappedEntity);
                Assert.False(wrappedEntity.OverridesEqualsOrGetHashCode);
                wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.IPocosWithEquals.First())).WrappedEntity;
                Assert.IsType<LightweightEntityWrapper<IPocoEntityWithEquals>>(wrappedEntity);
                Assert.True(wrappedEntity.OverridesEqualsOrGetHashCode);
                wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.WithRels.First())).WrappedEntity;
                Assert.IsType<EntityWrapperWithRelationships<EntityWithRelationships>>(wrappedEntity);
                Assert.False(wrappedEntity.OverridesEqualsOrGetHashCode);
                wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.WithRelsAndEquals.First())).WrappedEntity;
                Assert.IsType<EntityWrapperWithRelationships<EntityWithRelationshipsAndEquals>>(wrappedEntity);
                Assert.True(wrappedEntity.OverridesEqualsOrGetHashCode);
                wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.Pocos.First())).WrappedEntity;
                Assert.IsType<EntityWrapperWithoutRelationships<PocoEntity>>(wrappedEntity);
                Assert.False(wrappedEntity.OverridesEqualsOrGetHashCode);
                wrappedEntity = ((EntityEntry)stateManager.GetObjectStateEntry(context.PocosWithEquals.First())).WrappedEntity;
                Assert.IsType<EntityWrapperWithoutRelationships<PocoEntityWithEquals>>(wrappedEntity);
                Assert.True(wrappedEntity.OverridesEqualsOrGetHashCode);
            }
        }
[ Fact ] public void Materialized_entities_have_override_Equals_flag_set_appropriately ( ) { using ( var context = new EntityTypesContext ( ) ) { var stateManager = ( ( IObjectContextAdapter ) context ) . ObjectContext . ObjectStateManager ; var wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . IPocos . First ( ) ) ) . WrappedEntity ; Assert . IsType < LightweightEntityWrapper < IPocoEntity > > ( wrappedEntity ) ; Assert . False ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . IPocosWithEquals . First ( ) ) ) . WrappedEntity ; Assert . IsType < LightweightEntityWrapper < IPocoEntityWithEquals > > ( wrappedEntity ) ; Assert . True ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . WithRels . First ( ) ) ) . WrappedEntity ; Assert . IsType < EntityWrapperWithRelationships < EntityWithRelationships > > ( wrappedEntity ) ; Assert . False ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . WithRelsAndEquals . First ( ) ) ) . WrappedEntity ; Assert . IsType < EntityWrapperWithRelationships < EntityWithRelationshipsAndEquals > > ( wrappedEntity ) ; Assert . True ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . Pocos . First ( ) ) ) . WrappedEntity ; Assert . IsType < EntityWrapperWithoutRelationships < PocoEntity > > ( wrappedEntity ) ; Assert . False ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; wrappedEntity = ( ( EntityEntry ) stateManager . GetObjectStateEntry ( context . PocosWithEquals . First ( ) ) ) . WrappedEntity ; Assert . IsType < EntityWrapperWithoutRelationships < PocoEntityWithEquals > > ( wrappedEntity ) ; Assert . True ( wrappedEntity . OverridesEqualsOrGetHashCode ) ; } }
Not really a unit test because of the complexity of setting up everything the materializer needs.
Not really a unit test because of the complexity of setting up everything the materializer needs .