public void GetByID_OneItem_ReturnsDMActionType()
        {
            // Arrange
            DMActionType entity = new DMActionType {
                ID = 1
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity));

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(1));
        }
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            DMActionType entity1 = new DMActionType {
                ID = 1
            };
            DMActionType entity2 = new DMActionType {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity2));

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(1));
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            DMActionType entity1 = new DMActionType {
                ID = 1
            };
            DMActionType entity2 = new DMActionType {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <DMActionType>(entity1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
        public void GetByID_NoItems_ThrowsKeyNotFoundException()
        {
            // Arrange
            DMActionType entity1 = new DMActionType {
                ID = 1
            };
            DMActionType entity2 = new DMActionType {
                ID = 2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMActionType>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <DMActionType>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <DMActionType>(entity2));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(2); });
        }