Ejemplo n.º 1
0
        public void OnSlidingUp()
        {
            if (isSwapping)
            {
                return;
            }

            isSwapping = true;
            swapper.SwapUp();
        }
Ejemplo n.º 2
0
        public void SwappingUpFromItemWillSwapItWithUpItem()
        {
            Vector2      expectedSelectedItemPosition = Vector2.up;
            Vector2      selectedItemInitialPosition  = Vector2.zero;
            Item         itemAbove    = CreateItem(expectedSelectedItemPosition);
            Item         selectedItem = CreateItem(selectedItemInitialPosition);
            ItemSearcher itemSearcher = CreateUpMockItemSearcher(() => itemAbove);
            Swapper      swapper      = CreateSwapper(itemSearcher);

            swapper.Initialize(selectedItem);

            swapper.SwapUp();
            Vector2 selectedItemPosition = selectedItem.Position;

            Assert.AreEqual(expectedSelectedItemPosition, selectedItemPosition);
        }
Ejemplo n.º 3
0
        public void ResetingWillReturnSwappedItemsToInitialPlaces()
        {
            Vector2      initialItemAbovePosition     = Vector2.up;
            Vector2      selectedItemInitialPosition  = Vector2.zero;
            Vector2      expectedSelectedItemPosition = selectedItemInitialPosition;
            Item         itemAbove    = CreateItem(initialItemAbovePosition);
            Item         selectedItem = CreateItem(selectedItemInitialPosition);
            ItemSearcher itemSearcher = CreateUpMockItemSearcher(() => itemAbove);
            Swapper      swapper      = CreateSwapper(itemSearcher);

            swapper.Initialize(selectedItem);

            swapper.SwapUp();
            swapper.Reset();
            Vector2 selectedItemPosition = selectedItem.Position;
            Vector2 itemAbovePosition    = itemAbove.Position;

            Assert.AreEqual(expectedSelectedItemPosition, selectedItemPosition);
            Assert.AreEqual(initialItemAbovePosition, itemAbovePosition);
        }