public void OnSlidingLeft() { if (isSwapping) { return; } isSwapping = true; swapper.SwapLeft(); }
public void SwappingLeftFromItemWillSwapItWithLeftItem() { Vector2 expectedSelectedItemPosition = Vector2.up; Vector2 selectedItemInitialPosition = Vector2.zero; Item itemLeft = CreateItem(expectedSelectedItemPosition); Item selectedItem = CreateItem(selectedItemInitialPosition); ItemSearcher itemSearcher = CreateLeftMockItemSearcher(() => itemLeft); Swapper swapper = CreateSwapper(itemSearcher); swapper.Initialize(selectedItem); swapper.SwapLeft(); Vector2 selectedItemPosition = selectedItem.Position; Assert.AreEqual(expectedSelectedItemPosition, selectedItemPosition); }
public void MatchScannerIsTriggeredAftwerCompleteSwapping() { Vector2 expectedSelectedItemPosition = Vector2.up; Vector2 selectedItemInitialPosition = Vector2.zero; Item itemLeft = CreateItem(expectedSelectedItemPosition, "apple"); Item selectedItem = CreateItem(selectedItemInitialPosition, "banana"); string neighborType = "banana"; ItemSearcher itemSearcher = CreateLeftMockItemSearcher(() => itemLeft, neighborType); MatchScannerTrigger matchScannerTrigger = CreateMatchScannerTrigger(); Swapper swapper = CreateSwapper(itemSearcher, matchScannerTrigger); swapper.Initialize(selectedItem); swapper.SwapLeft(); swapper.CompleteSwap(); bool wasMatchScannerTriggerCalled = (matchScannerTrigger as MockMatchScannerTrigger).WasCalled; Assert.IsTrue(wasMatchScannerTriggerCalled); }
public void EndingSlideWhenThereIsNotAMatchWillLeaveItemsAtInitialPlaces() { Vector2 expectedSelectedItemPosition = Vector2.up; Vector2 selectedItemInitialPosition = Vector2.zero; Item itemLeft = CreateItem(expectedSelectedItemPosition, "apple"); Item selectedItem = CreateItem(selectedItemInitialPosition, "banana"); string neighborType = "apple"; ItemSearcher itemSearcher = CreateLeftMockItemSearcher(() => new NullItem(), neighborType); Swapper swapper = CreateSwapper(itemSearcher); swapper.Initialize(selectedItem); swapper.SwapLeft(); swapper.CompleteSwap(); Vector2 selectedItemPosition = selectedItem.Position; Vector2 itemLeftPosition = itemLeft.Position; Assert.AreEqual(selectedItemInitialPosition, selectedItemPosition); Assert.AreEqual(expectedSelectedItemPosition, itemLeftPosition); Assert.IsFalse((itemSearcher as MockItemSearcher).HasItemSwapped); }