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

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

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

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

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

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

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.AreNotSame(entity2, _cache.GetByID(2));
        }
コード例 #4
0
        public void GetByID_NoItems_ThrowsKeyNotFoundException()
        {
            // Arrange
            SpaceEncounter entity1 = new SpaceEncounter {
                ID = 1
            };
            SpaceEncounter entity2 = new SpaceEncounter {
                ID = 2
            };

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

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