Пример #1
0
        public void TestGetCommandUnauthorized()
        {
            var dialogShown        = false;
            var stubIDialogService = new StubIDialogService();

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

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

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
        }
Пример #2
0
        public void TestGetCommandOther()
        {
            var messageToShow = "Error Message";

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

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

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

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
Пример #3
0
        public void TestGetCommandUnauthorized()
        {
            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 checkRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                checkRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.Unauthorized
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(checkRequested);
        }
Пример #4
0
        public void TestCheckCommandOther()
        {
            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 getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student> {
                    Status = ServiceResultStatus.Exception,
                    Message = messageToShow
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsTrue(dialogShown);
            Assert.AreEqual(
                UvpClient.App.HttpClientErrorMessage + messageToShow,
                messageShown);
            Assert.IsTrue(getMeRequested);
        }
Пример #5
0
        public void TestGetCommandSucceeded()
        {
            var studentToReturn = new Student();

            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 getMeRequested      = false;
            var stubIStudentService = new StubIStudentService();

            stubIStudentService.GetMeAsync(async() => {
                getMeRequested = true;
                return(new ServiceResult <Student>
                {
                    Status = ServiceResultStatus.OK, Result = studentToReturn
                });
            });

            var meViewModel =
                new MeViewModel(stubIStudentService, stubIDialogService);

            meViewModel.GetCommand.Execute(null);

            Assert.IsFalse(rootFrameNavigated);
            Assert.IsFalse(dialogShown);
            Assert.IsTrue(getMeRequested);
            Assert.AreSame(studentToReturn, meViewModel.Me);
        }