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 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); }
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); }
private void Start() { swapper.Initialize(currentItem); }