public void Base_class_value_property_returns_same_as_strongly_typed_value_property() { var key = new SimpleEntityKey <int>(new Mock <IEntityType>().Object, 77); Assert.Equal(77, key.Value); Assert.Equal(77, ((EntityKey)key).Value); }
public void Base_class_value_property_returns_same_as_strongly_typed_value_property() { var key = new SimpleEntityKey<int>(new Mock<IEntityType>().Object, 77); Assert.Equal(77, key.Value); Assert.Equal(77, ((EntityKey)key).Value); }
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 entityKey = new SimpleEntityKey<int>(categoryType, 77); var valueBuffer = new ValueBuffer(new object[] { 77, "Bjork", null }); var entry = stateManager.StartTracking(categoryType, entityKey, category, valueBuffer); Assert.Same(entry, stateManager.StartTracking(categoryType, entityKey, category, valueBuffer)); }
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 entityKey = new SimpleEntityKey <int>(categoryType, 77); var valueBuffer = new ValueBuffer(new object[] { 77, "Bjork", null }); var entry = stateManager.StartTracking(categoryType, entityKey, category, valueBuffer); Assert.Same(entry, stateManager.StartTracking(categoryType, entityKey, category, valueBuffer)); }
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 entityKey = new SimpleEntityKey<int>(categoryType, 77); var valueBuffer = new ValueBuffer(new object[] { 77, "Bjork", null }); stateManager.StartTracking(categoryType, entityKey, new Category { Id = 77 }, valueBuffer); Assert.Equal( Strings.IdentityConflict("Category"), Assert.Throws<InvalidOperationException>( () => stateManager.StartTracking(categoryType, entityKey, new Category { Id = 77 }, valueBuffer)).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 entityKey = new SimpleEntityKey <int>(categoryType, 77); var valueBuffer = new ValueBuffer(new object[] { 77, "Bjork", null }); stateManager.StartTracking(categoryType, entityKey, new Category { Id = 77 }, valueBuffer); Assert.Equal( Strings.IdentityConflict("Category"), Assert.Throws <InvalidOperationException>( () => stateManager.StartTracking(categoryType, entityKey, new Category { Id = 77 }, valueBuffer)).Message); }