public void Generic_DbCollectionEntry_Name_returns_name_of_property_from_internal_entry() { var internalEntry = new InternalCollectionEntry( new Mock <InternalEntityEntryForMock <FakeEntity> >().Object, FakeWithProps.CollectionMetadata); Assert.Equal("Collection", internalEntry.Name); }
public void InternalCollectionEntry_Name_works_even_when_used_with_Detached_entity() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalCollectionEntry(mockInternalEntry.Object, FakeWithProps.CollectionMetadata); Assert.Equal("Collection", internalEntry.Name); }
public void InternalCollectionEntry_Query_throws_if_used_with_Detached_entity() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalCollectionEntry(mockInternalEntry.Object, FakeWithProps.CollectionMetadata); Assert.Equal( Strings.DbPropertyEntry_NotSupportedForDetached("Query", "Collection", "FakeEntity"), Assert.Throws <InvalidOperationException>(() => internalEntry.Query()).Message); }
public void InternalCollectionEntry_throws_setting_current_value_from_detached_entity_if_navigation_property_has_been_removed() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalCollectionEntry(mockInternalEntry.Object, FakeWithProps.CollectionMetadata); Assert.Equal( Strings.DbCollectionEntry_CannotSetCollectionProp("Collection", typeof(FakeEntity).ToString()), Assert.Throws <NotSupportedException>(() => { internalEntry.CurrentValue = null; }).Message); }
public void InternalCollectionEntry_throws_getting_current_value_from_detached_entity_if_navigation_property_has_been_removed() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalCollectionEntry(mockInternalEntry.Object, FakeWithProps.CollectionMetadata); Assert.Equal( Strings.DbPropertyEntry_NotSupportedForDetached("CurrentValue", "Collection", "FakeEntity"), Assert.Throws <InvalidOperationException>(() => { var _ = internalEntry.CurrentValue; }).Message); }
InternalCollectionEntry_does_nothing_if_attempting_to_set_the_actual_EntityCollection_as_a_current_value_when_navigation_property_has_been_removed_from_entity () { var relatedCollection = new EntityCollection <FakeEntity>(); var internalEntry = new InternalCollectionEntry( MockHelper.CreateMockInternalEntityEntry(new FakeEntity(), entityCollection: relatedCollection).Object, FakeWithProps.CollectionMetadata); internalEntry.CurrentValue = relatedCollection; // Test that it doesn't throw }
InternalCollectionEntry_gets_current_value_that_is_the_RelatedEnd_if_navigation_property_has_been_removed_from_entity() { var relatedCollection = new EntityCollection <FakeEntity>(); var internalEntry = new InternalCollectionEntry( MockHelper.CreateMockInternalEntityEntry(new FakeEntity(), entityCollection: relatedCollection).Object, FakeWithProps.CollectionMetadata); var propValue = internalEntry.CurrentValue; Assert.Same(relatedCollection, propValue); }
InternalCollectionEntry_throws_when_attempting_to_set_a_new_collection_when_navigation_property_has_been_removed_from_entity () { var internalEntry = new InternalCollectionEntry( MockHelper.CreateMockInternalEntityEntry(new FakeEntity(), entityCollection: new EntityCollection <FakeEntity>()). Object, FakeWithProps.CollectionMetadata); Assert.Equal( Strings.DbCollectionEntry_CannotSetCollectionProp("Collection", typeof(FakeEntity).ToString()), Assert.Throws <NotSupportedException>(() => internalEntry.CurrentValue = new List <FakeEntity>()).Message); }
public async Task InternalCollectionEntry_LoadAsync_throws_if_used_with_Detached_entity() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalCollectionEntry(mockInternalEntry.Object, FakeWithProps.CollectionMetadata); Assert.Equal( Strings.DbPropertyEntry_NotSupportedForDetached("LoadAsync", "Collection", "FakeEntity"), (await Assert.ThrowsAsync <InvalidOperationException>( () => internalEntry.LoadAsync(CancellationToken.None))).Message); }
private void InternalCollectionEntry_gets_current_value_from_entity_if_property_exists_implementation(bool isDetached) { var relatedCollection = new List <FakeEntity>(); var entity = new FakeWithProps { Collection = relatedCollection }; var internalEntry = new InternalCollectionEntry( MockHelper.CreateMockInternalEntityEntry( entity, isDetached).Object, FakeWithProps.CollectionMetadata); var propValue = internalEntry.CurrentValue; Assert.Same(relatedCollection, propValue); }