public void GetByID_OneItem_ReturnsBaseStructureType() { // Arrange BaseStructureType entity = new BaseStructureType { ID = 1 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity)); // Assert Assert.AreNotSame(entity, _cache.GetByID(1)); }
public void GetByID_TwoItems_ReturnsCorrectObject() { // Arrange BaseStructureType entity1 = new BaseStructureType { ID = 1 }; BaseStructureType entity2 = new BaseStructureType { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByID(1)); Assert.AreNotSame(entity2, _cache.GetByID(2)); }
public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange BaseStructureType entity1 = new BaseStructureType { ID = 1 }; BaseStructureType entity2 = new BaseStructureType { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <BaseStructureType>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); }); Assert.AreNotSame(entity2, _cache.GetByID(2)); }
public void GetByID_NoItems_ThrowsKeyNotFoundException() { // Arrange BaseStructureType entity1 = new BaseStructureType { ID = 1 }; BaseStructureType entity2 = new BaseStructureType { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <BaseStructureType>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <BaseStructureType>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <BaseStructureType>(entity2)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); }); Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(2); }); }