Esempio n. 1
0
        public void DestroyableObjectsAreAddedToCache()
        {
            // Arrange
            const string destroyableId = "destr_id";
            var          destroyable   = new Mock <IDestroyableObject>();

            destroyable.SetupGet(d => d.Id).Returns(destroyableId);

            var mapCellsFactory = new Func <IAreaMapCellInternal>(() => new AreaMapCell(new Mock <IEnvironment>().Object));

            var map = new AreaMap(1, mapCellsFactory, 5, 5);

            // Act
            map.AddObject(1, 1, destroyable.Object);
            var cachedDestroyable = map.GetDestroyableObject(destroyableId);

            // Assert
            Assert.AreSame(destroyable.Object, cachedDestroyable);
        }
Esempio n. 2
0
        public void RemovedDestroyableObjectsAreRemovedFromCache()
        {
            // Arrange
            const int    posX          = 1;
            const int    posY          = 1;
            const string destroyableId = "destr_id";
            var          destroyable   = new Mock <IDestroyableObject>();

            destroyable.SetupGet(d => d.Id).Returns(destroyableId);

            var mapCellsFactory = new Func <IAreaMapCellInternal>(() => new AreaMapCell(new Mock <IEnvironment>().Object));

            var map      = new AreaMap(1, mapCellsFactory, 5, 5);
            var position = new Point(posX, posY);

            // Act
            map.AddObject(position, destroyable.Object);
            map.RemoveObject(position, destroyable.Object);
            var cachedDestroyable = map.GetDestroyableObject(destroyableId);

            // Assert
            Assert.IsNull(cachedDestroyable);
        }