public async Task TestSelectionItemChangedMatchesPairs() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); Tile secondTile = null; for (int i = 1; i < vm.PairsTileItems.Count; i++) { if (String.Equals(vm.PairsTileItems[0].TileFront, vm.PairsTileItems[i].TileFront)) { secondTile = vm.PairsTileItems[i]; break; } } vm.SelectedTile = secondTile; await vm.SelectionItemChangedAsync(); foreach (var currTile in vm.PairsTileItems) { if (currTile == vm.PairsTileItems[0] || currTile == secondTile) { Assert.IsTrue(currTile.FrontShown); } else { Assert.IsFalse(currTile.FrontShown); } } }
public async Task TestSelectionItemChangedDoesntMatchMismatchedPair() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); Tile secondTile; if (String.Equals(vm.PairsTileItems[0].TileFront, vm.PairsTileItems[1].TileFront)) { secondTile = vm.PairsTileItems[2]; } else { secondTile = vm.PairsTileItems[1]; } vm.SelectedTile = secondTile; await vm.SelectionItemChangedAsync(); foreach (var currTile in vm.PairsTileItems) { Assert.IsFalse(currTile.FrontShown); } }
public async Task TestSelectionItemChangedDoesNothingWhenCalledSecondTimeSameTile() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); Assert.IsTrue(vm.PairsTileItems[0].FrontShown); for (int i = 1; i < vm.PairsTileItems.Count; i++) { Assert.IsFalse(vm.PairsTileItems[i].FrontShown); } }
public async Task TestSelectionItemChangedClearsSelectedTile() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); Assert.IsNull(vm.SelectedTile); }
public async Task TestSelectionItemChangedShowsTileWhenSelected() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService); vm.SelectedTile = vm.PairsTileItems[0]; await vm.SelectionItemChangedAsync(); Assert.IsTrue(vm.PairsTileItems[0].FrontShown); }
public async Task TestSelectionItemChangedDoesNothingWhenCalledWithNull() { PairsGameViewModel vm = new PairsGameViewModel(dependencyService) { SelectedTile = null }; await vm.SelectionItemChangedAsync(); foreach (var currTile in vm.PairsTileItems) { Assert.IsFalse(currTile.FrontShown); } Assert.AreEqual(null, vm.SelectedTile); Assert.AreEqual(false, vm.IsBusy); }