public void OnSlidingUp() { if (isSwapping) { return; } isSwapping = true; swapper.SwapUp(); }
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); }
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); }