public void TestMessageShowOnValidationPass()
        {
            // reset...
            MockViewModelHost.Current.Reset();

            // get the view model, passing in our mock host...
            ILogonPageViewModel model = ViewModelFactory.Current.GetHandler<ILogonPageViewModel>(MockViewModelHost.Current);

            // set the data...
            model.Username = "******";
            model.Password = "******";

            // create a task wrapper that can handle the success delegate from the model and patch it
            // into a local variable for testing... (this anonymous method simulates the success callback
            // from the event...)
            TaskWrapper wrapper = new TaskWrapper();

            // this call should work...
            model.LogonCommand.Execute(wrapper);

            // wait until it's finished executing...
            wrapper.WaitIfTaskAvailable();

            // check that we showed no error messages...
            Assert.AreEqual(0, MockViewModelHost.Current.NumErrorBucketMessages);
            Assert.IsNull(MockViewModelHost.Current.Fatal);
        }
        public void TestCallbackRaisedOnSuccess()
        {
            // reset...
            MockViewModelHost.Current.Reset();

            // get the view model, passing in our mock host...
            ILogonPageViewModel model = ViewModelFactory.Current.GetHandler<ILogonPageViewModel>(MockViewModelHost.Current);

            // set the data...
            model.Username = "******";
            model.Password = "******";

            // create a task wrapper that can handle the success delegate from the model and patch it
            // into a local variable for testing... (this anonymous method simulates the success callback
            // from the event...)
            LogonResult result = null;
            TaskWrapper wrapper = new TaskWrapper((theResult) => result = (LogonResult)theResult);

            // this call should work...
            model.LogonCommand.Execute(wrapper);

            // wait until it's finished executing...
            wrapper.WaitIfTaskAvailable();

            // check that we called the callback...
            Assert.IsTrue(wrapper.SuccessCalled);

            // check that we got a token in the result...
            Assert.IsFalse(string.IsNullOrEmpty(result.Token));
        }
        public void TestRegistrationPageNavigation()
        {
            // reset...
            MockViewModelHost.Current.Reset();

            // get the view model, passing in our mock host...
            ILogonPageViewModel model = ViewModelFactory.Current.GetHandler<ILogonPageViewModel>(MockViewModelHost.Current);

            // this call should work...
            TaskWrapper wrapper = new TaskWrapper();
            model.RegisterCommand.Execute(wrapper);

            // wait until it's finished executing...
            wrapper.WaitIfTaskAvailable();

            // check that we did navigate to the logon page...
            Assert.AreEqual(1, MockViewModelHost.Current.NumPageChanges);
            Assert.AreEqual(typeof(IRegisterPageViewModel), MockViewModelHost.Current.LastPageChange);
        }
        public void TestNavigateToLogonOnSuccess()
        {
            // reset...
            MockViewModelHost.Current.Reset();

            // get the view model, passing in our mock host...
            ILogonPageViewModel model = ViewModelFactory.Current.GetHandler<ILogonPageViewModel>(MockViewModelHost.Current);

            // set the data...
            model.Username = "******";
            model.Password = "******";

            // this call should work...
            TaskWrapper wrapper = new TaskWrapper();
            model.LogonCommand.Execute(wrapper);

            // wait until it's finished executing...
            wrapper.WaitIfTaskAvailable();

            // check that we did navigate to the logon page...
            Assert.AreEqual(1, MockViewModelHost.Current.NumPageChanges);
            Assert.AreEqual(typeof(ILogonPageViewModel), MockViewModelHost.Current.LastPageChange);
        }