public void TestRefreshCommandUnauthorized() { var rootFrameNavigated = false; var stubRootNavigationService = new StubIRootNavigationService(); stubRootNavigationService.Navigate( (sourcePageType, parameter, navigationTransition) => rootFrameNavigated = true); var dialogShown = false; var stubDialogService = new StubIDialogService(); stubDialogService.ShowAsync(async message => dialogShown = true); var checkRequested = false; var stubMyUvpService = new StubIMyUvpService(); stubMyUvpService.GetAsync(async() => { checkRequested = true; return(new ServiceResult <MyUvp> { Status = ServiceResultStatus.Unauthorized }); }); var myUvpViewModel = new MyUvpViewModel(stubMyUvpService, stubDialogService, stubRootNavigationService, null); myUvpViewModel.RefreshCommand.Execute(null); Assert.IsFalse(rootFrameNavigated); Assert.IsFalse(dialogShown); Assert.IsTrue(checkRequested); }
public void TestSignOutCommand() { var logoutRequest = false; var stubIIdentityService = new StubIIdentityService(); stubIIdentityService.SignOutAsync(async() => { logoutRequest = true; return(new ServiceResult { Status = ServiceResultStatus.NoContent }); }); var resetRequest = false; var stubITileService = new StubITileService(); stubITileService.Reset(() => resetRequest = true); var myUvpViewModel = new MyUvpViewModel(null, null, null, stubIIdentityService, stubITileService); myUvpViewModel.SignOutCommand.Execute(null); Assert.IsTrue(logoutRequest); Assert.IsTrue(resetRequest); }
public void TestSignOutCommand() { var logoutRequest = false; var stubIIdentityService = new StubIIdentityService(); stubIIdentityService.SignOut(() => logoutRequest = true); var myUvpViewModel = new MyUvpViewModel(null, null, null, stubIIdentityService); myUvpViewModel.SignOutCommand.Execute(null); Assert.IsTrue(logoutRequest); }
public void TestRefreshCommandSucceeded() { var myUvpToReturn = new MyUvp { Me = new Student { StudentId = "stuid" } }; var rootFrameNavigated = false; var stubRootNavigationService = new StubIRootNavigationService(); stubRootNavigationService.Navigate( (sourcePageType, parameter, navigationTransition) => rootFrameNavigated = true); var dialogShown = false; var stubDialogService = new StubIDialogService(); stubDialogService.ShowAsync(async message => dialogShown = true); var getRequested = false; var myUvpService = new StubIMyUvpService(); myUvpService.GetAsync(async() => { getRequested = true; return(new ServiceResult <MyUvp> { Status = ServiceResultStatus.OK, Result = myUvpToReturn }); }); var stubITileService = new StubITileService(); var studentIdSet = ""; stubITileService.SetUpdate(studentId => studentIdSet = studentId); var myUvpViewModel = new MyUvpViewModel(myUvpService, stubDialogService, stubRootNavigationService, null, stubITileService); myUvpViewModel.RefreshCommand.Execute(null); Assert.IsFalse(rootFrameNavigated); Assert.IsFalse(dialogShown); Assert.IsTrue(getRequested); Assert.AreSame(myUvpToReturn, myUvpViewModel.MyUvp); Assert.AreEqual(myUvpToReturn.Me.StudentId, studentIdSet); }
public void TestOpenPrivacyDataCommand() { var rootFrameNavigated = false; var stubIRootNavigationService = new StubIRootNavigationService(); stubIRootNavigationService.Navigate((type, parameter, transition) => rootFrameNavigated = type == typeof(PrivacyDataPage) && parameter == null && transition == NavigationTransition .DrillInNavigationTransition); var myUvpViewModel = new MyUvpViewModel(null, null, stubIRootNavigationService, null); myUvpViewModel.OpenPrivacyDataCommand.Execute(null); Assert.IsTrue(rootFrameNavigated); }
public void TestCheckCommandOther() { var messageToShow = "Error Message"; var rootFrameNavigated = false; var stubRootNavigationService = new StubIRootNavigationService(); stubRootNavigationService.Navigate( (sourcePageType, parameter, navigationTransition) => rootFrameNavigated = true); var messageShown = ""; var dialogShown = false; var stubDialogService = new StubIDialogService(); stubDialogService.ShowAsync(async message => { dialogShown = true; messageShown = message; }); var bindRequested = false; var myUvpService = new StubIMyUvpService(); myUvpService.GetAsync(async() => { bindRequested = true; return(new ServiceResult <MyUvp> { Status = ServiceResultStatus.Exception, Message = messageToShow }); }); var myUvpViewModel = new MyUvpViewModel(myUvpService, stubDialogService, stubRootNavigationService, null); myUvpViewModel.RefreshCommand.Execute(null); Assert.IsFalse(rootFrameNavigated); Assert.IsTrue(dialogShown); Assert.AreEqual( UvpClient.App.HttpClientErrorMessage + messageToShow, messageShown); Assert.IsTrue(bindRequested); }
public void TestOpenAnnouncementCommand() { var announcementToNavigate = new Announcement(); var rootFrameNavigated = false; var stubIRootNavigationService = new StubIRootNavigationService(); stubIRootNavigationService.Navigate((type, parameter, transition) => rootFrameNavigated = type == typeof(AnnouncementPage) && parameter == announcementToNavigate && transition == NavigationTransition .DrillInNavigationTransition); var myUvpViewModel = new MyUvpViewModel(null, null, stubIRootNavigationService, null); myUvpViewModel.OpenAnnouncementCommand.Execute( announcementToNavigate); Assert.IsTrue(rootFrameNavigated); }
public void TestOpenPeerWorkGroupEvaluationCommand() { var peerWorkGroupEvaluationToNavigate = new PeerWorkGroupEvaluation(); var rootFrameNavigated = false; var stubIRootNavigationService = new StubIRootNavigationService(); stubIRootNavigationService.Navigate((type, parameter, transition) => rootFrameNavigated = type == typeof(PeerWorkGroupEvaluationPage) && parameter == peerWorkGroupEvaluationToNavigate && transition == NavigationTransition .DrillInNavigationTransition); var myUvpViewModel = new MyUvpViewModel(null, null, stubIRootNavigationService, null); myUvpViewModel.OpenPeerWorkGroupEvaluationCommand.Execute( peerWorkGroupEvaluationToNavigate); Assert.IsTrue(rootFrameNavigated); }