예제 #1
0
        public void OnRemoveItem_WhenNoItemExists_ThrowsException()
        {
            var item          = new TestBoardItem(Vector2Int.zero);
            var boardRegistry = new BoardRegistry <TestBoardItem>();

            Assert.Throws <Exception>(() => boardRegistry.Remove(item));
        }
예제 #2
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));
        }
예제 #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
        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));
        }
예제 #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);
        }