public async Task It_disposes_modal_VM_when_closing_modals() { var sut = new BlindSectionsNavigator(); var modalNavigator = await sut.OpenModal(CancellationToken.None, SectionsNavigatorRequest.GetOpenModalRequest(StackNavigatorRequest.GetNavigateRequest(() => new TestVM(1), suppressTransition: true))); var vm = (TestVM)modalNavigator.State.Stack.Last().ViewModel; await sut.CloseModal(CancellationToken.None, SectionsNavigatorRequest.GetCloseModalRequest(null)); Assert.True(vm.IsDisposed); }
public async Task Interface_contract_changes_can_be_detected() { var ct = CancellationToken.None; var navigator = new BlindSectionsNavigator("Section1", "Section2"); // If the core contract changes, we get compilation errors here. ISectionStackNavigator sectionNavigator = await navigator.SetActiveSection(ct, SectionsNavigatorRequest.GetSetActiveSectionRequest("Section1")); IModalStackNavigator modalNavigator = await navigator.OpenModal(ct, SectionsNavigatorRequest.GetOpenModalRequest(StackNavigation.StackNavigatorRequest.GetNavigateRequest(() => new TestVM()), "modalName", 0)); await navigator.CloseModal(ct, SectionsNavigatorRequest.GetCloseModalRequest("modalName", 0)); }
public async Task It_produces_failed_notifications_for_CloseModal() { var sut = new BlindSectionsNavigator(); var eventList = new List <(object sender, SectionsNavigatorEventArgs args)>(); var modalNavigator = await sut.OpenModal(CancellationToken.None, SectionsNavigatorRequest.GetOpenModalRequest(StackNavigatorRequest.GetNavigateRequest(() => new TestVM(1, throwOnDispose: true), suppressTransition: true))); sut.StateChanged += OnStateChanged; void OnStateChanged(object sender, SectionsNavigatorEventArgs args) { eventList.Add((sender, args)); } await Assert.ThrowsAsync <InvalidOperationException>(async() => await sut.CloseModal(CancellationToken.None, SectionsNavigatorRequest.GetCloseModalRequest(null))); sut.StateChanged -= OnStateChanged; Assert.Null(sut.State.ActiveSection); Assert.Equal(2, eventList.Count); Assert.Equal(NavigatorRequestState.Processing, eventList[0].args.CurrentState.LastRequestState); Assert.Equal(NavigatorRequestState.FailedToProcess, eventList[1].args.CurrentState.LastRequestState); }