public void Retreiving_key_with_wrong_type_returns_null() { var entity1 = new TestEntity1("woftam", "hello"); var entity2 = new TestEntity2("woftam2", 123); Writer.Add(entity1.Identifier, entity1); Writer.Add(entity2.Identifier, entity2); Assert.IsNull(Reader.GetByKey <TestEntity2>("woftam")); }
public void Deleting_entity_leaves_entities_of_other_types_with_same_key_intact() { var entity1 = new TestEntity1("woftam1", "string1"); var entity2 = new TestEntity2("woftam1", 123); Writer.Add(entity1.Identifier, entity1); Writer.Add(entity2.Identifier, entity2); Writer.Delete <TestEntity1>(entity1.Identifier); Assert.AreEqual(entity2, Reader.GetByKey <TestEntity2>(entity2.Identifier)); }
public void Multiple_types_of_entity_with_same_key_can_be_added_and_retreived() { var entity1 = new TestEntity1("woftam", "hello"); var entity2 = new TestEntity2("woftam", 123); Writer.Add(entity1.Identifier, entity1); Writer.Add(entity2.Identifier, entity2); Assert.AreEqual(entity1, Reader.GetByKey <TestEntity1>(entity1.Identifier)); Assert.AreEqual(entity2, Reader.GetByKey <TestEntity2>(entity2.Identifier)); }
public void Update_where_leaves_matching_entities_of_other_types_intact() { var entity1 = new TestEntity1("id", "initialValue"); var entity2 = new TestEntity2("id", 111); var expected = new TestEntity2("id", 111); Writer.Add(entity1.Identifier, entity1); Writer.Add(entity2.Identifier, entity2); Writer.UpdateWhere <TestEntity1>(e => e.Identifier.Equals("id"), e => e.Identifier = "new"); var actual = Reader.GetByKey <TestEntity2>(entity2.Identifier); Assert.AreEqual(expected, actual); }
public void Updating_an_entity_leaves_entities_of_other_types_with_same_key_intact() { var action = new Action <TestEntity1>(e => e.Identifier = "newvalue"); var entity1 = new TestEntity1("id", "initialValue"); var entity2 = new TestEntity2("id", 111); var expected = new TestEntity2("id", 111); Writer.Add(entity1.Identifier, entity1); Writer.Add(entity2.Identifier, entity2); Writer.Update(entity1.Identifier, action); var actual = Reader.GetByKey <TestEntity2>(entity2.Identifier); Assert.AreEqual(expected, actual); }