public async Task middleware_continues() { var middleware = new PreExecuteMiddleware( Contributor(e => Task.FromResult(PipelineContinuation.RenderNow))) .Compose(Next); await middleware.Invoke(Env); ContributorCalled.ShouldBeTrue(); NextCalled.ShouldBeTrue(); Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow); }
public async Task contributor_not_executed() { Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.RenderNow; var middleware = new RequestMiddleware( Contributor(e => Task.FromResult(PipelineContinuation.Continue))) .Compose(Next); await middleware.Invoke(Env); NextCalled.ShouldBeTrue(); ContributorCalled.ShouldBeFalse(); }
public async Task next_middleware_isnt_executed() { Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue; var middleware = new ResponseMiddleware( Contributor(e => Task.FromResult(PipelineContinuation.RenderNow))); await middleware.Invoke(Env); ContributorCalled.ShouldBeTrue(); NextCalled.ShouldBeFalse(); Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow); }
private async Task _editBooking(SumUpViewModel sumUpVM) { try { LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(sumUpVM); BookingViewModel bookingVM = await BookingViewModel.LoadAsync(_navigation, _booking, prevNode); NextCalled?.Invoke(this, sumUpVM); } catch (Exception ex) { Logger.Log(ex); } }
public async Task pipeline_is_in_RenderNow() { Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue; var middleware = new RequestMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.RenderNow))) .Compose(Next); await middleware.Invoke(Env); ContributorCalled.ShouldBeTrue(); NextCalled.ShouldBeTrue(); Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow); }
public async Task contributor_executed() { Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue; var middleware = new RequestMiddleware( Contributor(e => { throw new InvalidOperationException("Should not throw"); })) .Compose(Next); await middleware.Invoke(Env); ContributorCalled.ShouldBeTrue(); NextCalled.ShouldBeTrue(); Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort); }
public void middleware_throws() { var middleware = new PreExecuteMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.Abort))) .Compose(Next); middleware.Invoke(Env).ShouldThrow <PipelineAbortedException>(); ContributorCalled.ShouldBeTrue(); NextCalled.ShouldBeFalse(); #pragma warning disable 618 Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort); #pragma warning restore 618 }
private async Task _validateBooking(BookingViewModel bookingVM) { try { await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking); LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(this); SumUpViewModel sumUpVM = new SumUpViewModel(_navigation, _booking, prevNode); NextCalled?.Invoke(null, this); } catch (Exception ex) { Logger.Log(ex); } }
private async void _searchClient_clientSelected(object sender, ClientEntity selectedClientEntity) { try { (sender as SearchClientsViewModel).ClientSelected -= _searchClient_clientSelected; _booking.Client = selectedClientEntity.Client; await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking); LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(this); SumUpViewModel sumUpVM = new SumUpViewModel(_navigation, _booking, prevNode); NextCalled?.Invoke(null, this); } catch (Exception ex) { Logger.Log(ex); } }
private void _sumUp(ClientViewModel clientVM) { try { int bookingCnt = clientVM.ClientEntity.Bookings.Count; Booking booking = clientVM.CurrentBookingVM.Booking; if (!(_navigation.Last.Value is SumUpViewModel)) { LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(this); SumUpViewModel sumUpVM = new SumUpViewModel(_navigation, clientVM.CurrentBookingVM.Booking, prevNode); } NextCalled?.Invoke(null, clientVM); } catch (Exception ex) { Logger.Log(ex); } }
private async Task _newClient(BookingViewModel bookingVM) { try { LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(bookingVM); ClientViewModel clientVM = new ClientViewModel(_navigation, _clientEntity, prevNode); await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking); bool success = _checkRoomCapacityWithBabies(bookingVM); if (success) { NextCalled?.Invoke(null, bookingVM); } } catch (Exception ex) { Logger.Log(ex); } }