コード例 #1
0
        public void GetByID_OneItem_ReturnsPerkLevelQuestRequirement()
        {
            // Arrange
            PerkLevelQuestRequirement entity = new PerkLevelQuestRequirement {
                ID = 1
            };

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

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(1));
        }
コード例 #2
0
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            PerkLevelQuestRequirement entity1 = new PerkLevelQuestRequirement {
                ID = 1
            };
            PerkLevelQuestRequirement entity2 = new PerkLevelQuestRequirement {
                ID = 2
            };

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

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(1));
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
コード例 #3
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            PerkLevelQuestRequirement entity1 = new PerkLevelQuestRequirement {
                ID = 1
            };
            PerkLevelQuestRequirement entity2 = new PerkLevelQuestRequirement {
                ID = 2
            };

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

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