public async Task UnpinFromStart_Changes_IsAppBarSticky() { var tileService = new MockTileService() { SecondaryTileExistsDelegate = (a) => false }; var target = new ItemDetailPageViewModel(null, new MockNavigationService(), null, null, null, tileService, null); target.SelectedProduct = new ProductViewModel(new Product() { ImageUri = new Uri("http://dummy-image-uri.com") }); // The AppBar should be sticky when the item is being unpinned tileService.UnpinTileDelegate = (a) => { Assert.IsTrue(target.IsAppBarSticky); return Task.FromResult(true); }; // Check if the AppBar is Sticky before unpinning Assert.IsFalse(target.IsAppBarSticky); await target.UnpinProductCommand.Execute(); // Check if the AppBar is Sticky after unpinning Assert.IsFalse(target.IsAppBarSticky); }
public async Task UnpinFromStart_FiresOnly_IfProductIsSelected_And_SecondaryTileDoesNotExist() { bool fired = false; var tileService = new MockTileService(); var target = new ItemDetailPageViewModel(null, new MockNavigationService(), null, null, null, tileService, null); // Case 1: Item not selected --> should not be fired tileService.SecondaryTileExistsDelegate = (a) => true; tileService.UnpinTileDelegate = (a) => { fired = true; return Task.FromResult(true); }; await target.UnpinProductCommand.Execute(); Assert.IsFalse(fired); // Case 2: Item selected but SecondaryTile does not exist --> should not be fired tileService.SecondaryTileExistsDelegate = (a) => false; target.SelectedProduct = new ProductViewModel(new Product() { ImageUri = new Uri("http://dummy-image-uri.com") }); await target.UnpinProductCommand.Execute(); Assert.IsFalse(fired); // Case 3: Item selected and SecondaryTile exists --> should be fired tileService.SecondaryTileExistsDelegate = (a) => true; await target.UnpinProductCommand.Execute(); Assert.IsTrue(fired); }