public void Generic_DbReferenceEntry_Name_returns_name_of_property_from_internal_entry()
            {
                var internalEntry = new InternalReferenceEntry(
                    new Mock <InternalEntityEntryForMock <FakeEntity> >().Object, FakeWithProps.ReferenceMetadata);

                Assert.Equal("Reference", internalEntry.Name);
            }
Exemplo n.º 2
0
            public void InternalReferenceEntry_Name_works_even_when_used_with_Detached_entity()
            {
                var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry(
                    new FakeEntity(), isDetached: true);
                var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata);

                Assert.Equal("Reference", internalEntry.Name);
            }
Exemplo n.º 3
0
            public void InternalReferenceEntry_Query_throws_if_used_with_Detached_entity()
            {
                var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry(
                    new FakeEntity(), isDetached: true);
                var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata);

                Assert.Equal(
                    Strings.DbPropertyEntry_NotSupportedForDetached("Query", "Reference", "FakeEntity"),
                    Assert.Throws <InvalidOperationException>(() => internalEntry.Query()).Message);
            }
Exemplo n.º 4
0
            public void InternalReferenceEntry_throws_setting_current_value_from_detached_entity_if_navigation_property_has_been_removed()
            {
                var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry(
                    new FakeEntity(), isDetached: true);
                var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata);

                Assert.Equal(
                    Strings.DbPropertyEntry_SettingEntityRefNotSupported("Reference", "FakeEntity", "Detached"),
                    Assert.Throws <NotSupportedException>(() => { internalEntry.CurrentValue = null; }).Message);
            }
Exemplo n.º 5
0
            InternalReferenceEntry_gets_current_value_from_RelatedEnd_if_navigation_property_has_been_removed_from_entity_implementation
                (FakeEntity relatedEntity)
            {
                var mockRelatedEnd = Core.Objects.DataClasses.MockHelper.CreateMockEntityReference(relatedEntity);

                var internalEntry =
                    new InternalReferenceEntry(
                        MockHelper.CreateMockInternalEntityEntry(new FakeEntity(), mockRelatedEnd.Object).Object,
                        FakeWithProps.ReferenceMetadata);

                var propValue = internalEntry.CurrentValue;

                Assert.Same(relatedEntity, propValue);
            }
Exemplo n.º 6
0
            private void InternalReferenceEntry_sets_current_value_onto_entity_if_property_exists_implementation(bool isDetached)
            {
                var entity = new FakeWithProps
                {
                    Reference = new FakeEntity()
                };
                var internalEntry = new InternalReferenceEntry(
                    MockHelper.CreateMockInternalEntityEntry(entity, isDetached).Object, FakeWithProps.ReferenceMetadata);

                var relatedEntity = new FakeEntity();

                internalEntry.CurrentValue = relatedEntity;

                Assert.Same(relatedEntity, entity.Reference);
            }