예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void OnEnd()
 {
     isSwapping = false;
     swapper.CompleteSwap();
 }