Beispiel #1
0
        public void TestBindCommandUnauthorized()
        {
            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => dialogShown = true);

            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested = true;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.BindCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(bindRequested);
        }
Beispiel #2
0
        public void TestBindCommandSucceeded()
        {
            var studentIdToRequest = "Student ID";

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = sourcePageType == typeof(MyUvpPage) &&
                                     parameter == null &&
                                     navigationTransition ==
                                     NavigationTransition
                                     .EntranceNavigationTransition);

            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => dialogShown = true);

            var studentIdRequested  = "";
            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested      = true;
                studentIdRequested = studentId;
                return(new ServiceResult
                {
                    Status = ServiceResultStatus.NoContent
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.StudentId = studentIdToRequest;
            bindingViewModel.BindCommand.Execute(null);

            Assert.IsTrue(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(bindRequested);
            Assert.AreEqual(studentIdToRequest, studentIdRequested);
        }
Beispiel #3
0
        public void TestBindCommandOther()
        {
            var messageToShow = "Error Message";

            var rootFrameNavigated         = false;
            var stubIRootNavigationService = new StubIRootNavigationService();

            stubIRootNavigationService.Navigate(
                (sourcePageType, parameter, navigationTransition) =>
                rootFrameNavigated = true);

            var messageShown       = "";
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

            stubIDialogService.ShowAsync(async message => {
                dialogShown  = true;
                messageShown = message;
            });

            var bindRequested       = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.BindAccountAsync(async studentId => {
                bindRequested = true;
                return(new ServiceResult {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var bindingViewModel = new BindingViewModel(
                stubIRootNavigationService, stubIDialogService,
                stubIStudentService);

            bindingViewModel.BindCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(bindRequested);
        }