public void SessionStateServiceSaveReturnsSuccess() { // arrange const HttpStatusCode expectedResult = HttpStatusCode.Created; var documentService = A.Fake <IDocumentService <SessionStateModel <TestSessionStateModel> > >(); A.CallTo(() => documentService.UpsertAsync(A <SessionStateModel <TestSessionStateModel> > .Ignored)).Returns(expectedResult); var sessionStateService = new SessionStateService <TestSessionStateModel>(documentService); // act var result = sessionStateService.SaveAsync(A.Fake <SessionStateModel <TestSessionStateModel> >()).Result; // assert A.CallTo(() => documentService.UpsertAsync(A <SessionStateModel <TestSessionStateModel> > .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private async void OnSuspending(object sender, SuspendingEventArgs e) { IsSuspending = true; try { var deferral = e.SuspendingOperation.GetDeferral(); //Bootstrap inform navigation service that app is suspending. NavigationService.Suspending(); // Save application state await SessionStateService.SaveAsync(); deferral.Complete(); } finally { IsSuspending = false; } }