コード例 #1
0
        public void OnAddItemTwice_ThrowsException()
        {
            var item          = new TestBoardItem(Vector2Int.one);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            boardRegistry.Add(item);

            Assert.Throws <Exception>(() => boardRegistry.Add(item));
        }
コード例 #2
0
        public void OnAddItem_IfItemAlreadyExistsAtPosition_ThrowsException()
        {
            var item          = new TestBoardItem(Vector2Int.one);
            var item2         = new TestBoardItem(Vector2Int.one);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            boardRegistry.Add(item);

            Assert.Throws <Exception>(() => boardRegistry.Add(item2));
        }
コード例 #3
0
        public void OnAddItem_AddsItemAtCorrectPosition()
        {
            var item          = new TestBoardItem(Vector2Int.one);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            boardRegistry.Add(item);

            Assert.That(boardRegistry.Get(Vector2Int.one) == item);
        }
コード例 #4
0
        public void OnAddItem_AddsItem()
        {
            var item          = new TestBoardItem(Vector2Int.one);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            boardRegistry.Add(item);

            Assert.That(boardRegistry.Exists(item));
        }
コード例 #5
0
ファイル: Board.cs プロジェクト: Abban/Slumberjacked-Core
        public void Add(IActor actor)
        {
            if (_static.Contains(actor.Position))
            {
                ExceptionLogger.Exception($"Tried to add an actor {actor} at a position where a wall exists ({actor.Position})");
            }

            _actors.Add(actor);
        }
コード例 #6
0
        public void OnRemoveItem_RemovesItem()
        {
            var position      = Vector2Int.one;
            var item          = new TestBoardItem(position);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            boardRegistry.Add(item);

            Assert.That(boardRegistry.Get(position) == item);

            boardRegistry.Remove(item);

            Assert.That(boardRegistry.Get(position) == null);
        }