Exemplo n.º 1
0
        public void GetByID_OneItem_ReturnsCraftBlueprintCategory()
        {
            // Arrange
            CraftBlueprintCategory entity = new CraftBlueprintCategory {
                ID = 1
            };

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

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

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

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(1));
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
Exemplo n.º 3
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            CraftBlueprintCategory entity1 = new CraftBlueprintCategory {
                ID = 1
            };
            CraftBlueprintCategory entity2 = new CraftBlueprintCategory {
                ID = 2
            };

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

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
Exemplo n.º 4
0
        public void GetByID_NoItems_ThrowsKeyNotFoundException()
        {
            // Arrange
            CraftBlueprintCategory entity1 = new CraftBlueprintCategory {
                ID = 1
            };
            CraftBlueprintCategory entity2 = new CraftBlueprintCategory {
                ID = 2
            };

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

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