public void Can_read_value() { var reader = new ObjectArrayValueReader(new object[] { 77, "Smokey" }); Assert.Equal(77, reader.ReadValue<int>(0)); Assert.Equal("Smokey", reader.ReadValue<string>(1)); }
public void IsNull_returns_true_only_if_value_is_null() { var reader = new ObjectArrayValueReader(new object[] { null, "" }); Assert.True(reader.IsNull(0)); Assert.False(reader.IsNull(1)); }
private static IEnumerable <TEntity> EntityQuery <TEntity>( QueryContext queryContext, IEntityType entityType, Func <IValueReader, EntityKey> entityKeyFactory, Func <IEntityType, IValueReader, object> materializer, bool queryStateManager) where TEntity : class { return(((InMemoryQueryContext)queryContext).Database .GetTables(entityType) .SelectMany(t => t.Select(vs => { var valueReader = new ObjectArrayValueReader(vs); var entityKey = entityKeyFactory(valueReader); return (TEntity)queryContext .QueryBuffer .GetEntity( entityType, entityKey, new EntityLoadInfo( valueReader, vr => materializer(t.EntityType, vr)), queryStateManager); }))); }
public void StartTracking_throws_for_null_entity_key_in_value_reader() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var valueReader = new ObjectArrayValueReader(new object[] { null, "Bjork", null }); Assert.Equal( Strings.InvalidPrimaryKey("Category"), Assert.Throws<InvalidOperationException>( () => stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader)).Message); }
public void StartTracking_is_no_op_if_entity_is_already_tracked() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var category = new Category { Id = 77 }; var valueReader = new ObjectArrayValueReader(new object[] { 77, "Bjork", null }); var entry = stateManager.StartTracking(categoryType, category, valueReader); Assert.Same(entry, stateManager.StartTracking(categoryType, category, valueReader)); }
public void StartTracking_throws_for_null_entity_key_in_value_reader() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var valueReader = new ObjectArrayValueReader(new object[] { null, "Bjork", null }); Assert.Equal( Strings.NullPrimaryKey("Category"), Assert.Throws <InvalidOperationException>( () => stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader)).Message); }
public void StartTracking_is_no_op_if_entity_is_already_tracked() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var category = new Category { Id = 77 }; var valueReader = new ObjectArrayValueReader(new object[] { 77, "Bjork", null }); var entry = stateManager.StartTracking(categoryType, category, valueReader); Assert.Same(entry, stateManager.StartTracking(categoryType, category, valueReader)); }
public void StartTracking_throws_if_different_instance_with_same_identity_is_already_tracked() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var valueReader = new ObjectArrayValueReader(new object[] { 77, "Bjork", null }); stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader); Assert.Equal( Strings.IdentityConflict("Category"), Assert.Throws<InvalidOperationException>( () => stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader)).Message); }
public void StartTracking_throws_if_different_instance_with_same_identity_is_already_tracked() { var model = BuildModel(); var categoryType = model.GetEntityType(typeof(Category)); var stateManager = CreateStateManager(model); var valueReader = new ObjectArrayValueReader(new object[] { 77, "Bjork", null }); stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader); Assert.Equal( Strings.IdentityConflict("Category"), Assert.Throws <InvalidOperationException>( () => stateManager.StartTracking(categoryType, new Category { Id = 77 }, valueReader)).Message); }
public void Can_get_count() { var reader = new ObjectArrayValueReader(new object[] { 77, "Smokey" }); Assert.Equal(2, reader.Count); }
public void Can_get_count() { var reader = new ObjectArrayValueReader(new object[] { 77, "Smokey" }); Assert.Equal(2, reader.Count); }