public void KeepTryingUntilFound2() { //Arrange MockPoppedStack mockPoppedStack = new(new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 3); MockPopping mockPopping = new(20, 5); mockPopping.AdditionalSetup(); Popping sut = mockPopping.Object; //Act sut.KeepTrying(mockPoppedStack.Object); //Assert List <int> expetedPopped = new List <int>() { 5, 6, 7, 8, 9, 10 }; sut.PoppedSoFar.Should().BeEquivalentTo(expetedPopped); sut.Tries.Should().Be(6); mockPopping.Protected().Verify("PopAndCheck", Times.Exactly(6), new object[] { mockPoppedStack.Object }); }
public Task RemovePageAsync(PopupPage page, bool animate = true) { lock (_locker) { if (page == null) { throw new NullReferenceException("Page can not be null"); } if (!_popupStack.Contains(page)) { throw new InvalidOperationException("The page has not been pushed yet or has been removed already"); } if (page.DisappearingTransactionTask != null) { return(page.DisappearingTransactionTask); } var task = InvokeThreadSafe(async() => { if (page.AppearingTransactionTask != null) { await page.AppearingTransactionTask; } lock (_locker) { if (!_popupStack.Contains(page)) { return; } } Popping?.Invoke(this, new PopupNavigationEventArgs(page, animate)); animate = CanBeAnimated(animate); if (animate) { await page.DisappearingAnimation(); page.DisposingAnimation(); } await RemoveAsync(page); lock (_locker) { _popupStack.Remove(page); page.DisappearingTransactionTask = null; Popped?.Invoke(this, new PopupNavigationEventArgs(page, animate)); } }); page.DisappearingTransactionTask = task; return(task); } }
/// <inheritdoc/> public Task PopAsync(bool animate = true) { Popping?.Invoke(this, new PopupNavigationEventArgs(_stack.Peek(), animate)); var poppedPage = _stack.Pop(); Popped?.Invoke(this, new PopupNavigationEventArgs(poppedPage, animate)); return(Task.CompletedTask); }