예제 #1
0
        public void CreateWindowReturnsCorrectResult(WindowLocator sut, FakeViewModel viewModel)
        {
            sut.Register <FakeViewModel, FakeWindow>();
            var actual = sut.CreateWindow(viewModel, null);

            Assert.IsType <FakeWindow>(actual);
        }
        public void SelectTemplateReturnsTemplateForFakeView()
        {
            var viewModel = new FakeViewModel();
            var template = _selector.SelectTemplate(viewModel, null);

            Assert.AreEqual(typeof(FakeView), template.VisualTree.Type);
        }
예제 #3
0
        public void ShowScreen_ActiveItemSetToScreen()
        {
            var fakeScreen = new FakeViewModel();
            var screenHost = new ScreenHost();

            screenHost.ShowScreen(fakeScreen);

            Assert.Equal(fakeScreen, screenHost.ActiveItem);
        }
        public void WhenSettingPropertyNoPropertyChangedListenersItWillUpdateThePropertyWithNoErrors()
        {
            var fakeViewModel = new FakeViewModel();

            Assert.AreEqual(null, fakeViewModel.WorkingProperty);

            fakeViewModel.WorkingProperty = "Test";

            Assert.AreEqual("Test", fakeViewModel.WorkingProperty);
        }
        public void BaseViewModel_instantiates_Metadata()
        {
            var defaultValues = new Mock <IViewModelDefaultValuesProvider>();

            defaultValues.Setup(x => x.Breadcrumb).Returns(new Mock <IBreadcrumbProvider>().Object);

            var model = new FakeViewModel(defaultValues.Object);

            Assert.NotNull(model.Metadata);
        }
        public void Skin_defaults_to_CustomerFocus()
        {
            var defaultValues = new Mock <IViewModelDefaultValuesProvider>();

            defaultValues.Setup(x => x.Breadcrumb).Returns(new Mock <IBreadcrumbProvider>().Object);

            var model = new FakeViewModel(defaultValues.Object);

            Assert.IsType <CustomerFocusSkin>(model.EsccWebsiteSkin);
        }
        public void ClientBaseUrl_has_trailing_slash_trimmed(string url)
        {
            var defaultValues = new Mock <IViewModelDefaultValuesProvider>();

            defaultValues.Setup(x => x.Breadcrumb).Returns(new Mock <IBreadcrumbProvider>().Object);
            defaultValues.Setup(x => x.ClientFileBaseUrl).Returns(new Uri(url));

            var model = new FakeViewModel(defaultValues.Object);

            Assert.Equal(url.TrimEnd('/'), model.ClientFileBaseUrl);
        }
예제 #8
0
        public void IUserInputBeforeClosedRequestScreenOpen_InteractivelyCloseAllScreens_ActiveItemStillIUserInputBeforeClosedRequestScreen()
        {
            var currentlyOpenFakeScreen = new FakeViewModel();
            var screenHost = new ScreenHost();

            screenHost.ShowScreen(currentlyOpenFakeScreen);

            screenHost.InteractivelyCloseAllScreens(() => { });

            Assert.Equal(currentlyOpenFakeScreen, screenHost.ActiveItem);
        }
예제 #9
0
        public void IUserInputBeforeClosedRequestScreenOpen_ShowScreen_ActiveItemStillIUserInputBeforeClosedRequestScreen()
        {
            var currentlyOpenFakeScreen = new FakeViewModel();
            var fakeScreenToOpen        = new FakeViewModel();
            var screenHost = new ScreenHost();

            screenHost.ShowScreen(currentlyOpenFakeScreen);

            screenHost.ShowScreen(fakeScreenToOpen);

            Assert.Equal(currentlyOpenFakeScreen, screenHost.ActiveItem);
        }
예제 #10
0
            public void CanNavigateToNewViewWithViewModel()
            {
                // Prepare
                var fakeViewModel  = new FakeViewModel();
                var navigationInfo = NavigationInfo.CreateSimple("viewKey", fakeViewModel);

                // Act
                var expectedViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo);

                // Verify
                Assert.IsNotNull(expectedViewInfo.View.DataContext);
            }
예제 #11
0
        public void ChangeProperty_RaisePropertyChangedEvent()
        {
            var viewModel = new FakeViewModel();

            bool eventRaised = false;

            viewModel.PropertyChanged += delegate { eventRaised = true; };

            viewModel.MyProperty = 1;

            Assert.IsTrue(eventRaised);
        }
        public void WhenPropertyIsNotifiedPropertyChangedEventWillBeCalled()
        {
            var fakeViewModel = new FakeViewModel();
            var hasBeenNotified = false;
            fakeViewModel.PropertyChanged +=
                (sender, args) => { if (args.PropertyName == "NotifiableProperty") hasBeenNotified = true; };

            Assert.IsFalse(hasBeenNotified);

            fakeViewModel.NotifyNotifiableProperty();

            Assert.IsTrue(hasBeenNotified);
        }
예제 #13
0
        public void IUserInputBeforeClosedRequestScreenOpen_InteractivelyCloseAllScreens_ContinuationSetsActiveItemToNull()
        {
            var    currentlyOpenFakeScreen = new FakeViewModel();
            var    screenHost   = new ScreenHost();
            Action continuation = () => { };

            currentlyOpenFakeScreen.ContinueIfCanCloseAction += c => continuation = c;
            screenHost.ShowScreen(currentlyOpenFakeScreen);

            screenHost.InteractivelyCloseAllScreens(() => { });
            continuation();

            Assert.Null(screenHost.ActiveItem);
        }
예제 #14
0
            public void CanNavigateToNewViewWithViewModel()
            {
                _uiTestHelper.ExecuteOnUIThread(() =>
                {
                    // Prepare
                    var fakeViewModel = new FakeViewModel();

                    // Act
                    var expectedViewInfo = _navigationManagerImpl.NavigateTo("view1", fakeViewModel);

                    // Verify
                    Assert.AreSame(expectedViewInfo.ViewInstance.DataContext, fakeViewModel);
                });
            }
예제 #15
0
            public void CanSupportViewKeyAwareViewModel()
            {
                _uiTestHelper.ExecuteOnUIThread(() =>
                {
                    // Prepare
                    var fakeViewKeyAwareViewModel = new FakeViewModel();

                    // Act
                    _navigationManagerImpl.NavigateTo("view1", fakeViewKeyAwareViewModel);

                    // Verify
                    Assert.AreEqual("view1", fakeViewKeyAwareViewModel.ViewInstanceKey);
                });
            }
예제 #16
0
        public void IUserInputBeforeClosedRequestScreenOpen_InteractivelyCloseAllScreens_ContinuationCallsContination()
        {
            var    currentlyOpenFakeScreen = new FakeViewModel();
            var    screenHost     = new ScreenHost();
            var    continationRun = false;
            Action continuation   = () => { };

            currentlyOpenFakeScreen.ContinueIfCanCloseAction += c => continuation = c;
            screenHost.ShowScreen(currentlyOpenFakeScreen);

            screenHost.InteractivelyCloseAllScreens(() => continationRun = true);
            continuation();

            Assert.True(continationRun);
        }
예제 #17
0
            public void CanSupportPresentableViewModel()
            {
                _uiTestHelper.ExecuteOnUIThread(() =>
                {
                    // Prepare
                    var fakePresentableViewModel = new FakeViewModel();

                    // Act
                    var expectedViewInfo = _navigationManagerImpl.NavigateTo("view1", fakePresentableViewModel);

                    // Verify
                    Assert.IsNotNull(expectedViewInfo.UIMetadata);
                    Assert.AreEqual("Label", expectedViewInfo.UIMetadata.Label);
                });
            }
예제 #18
0
        public async Task ShouldSaveModel()
        {
            var expected = new FakeViewModel
            {
                Id = Guid.NewGuid()
            };

            SetupCreateOrUpdate <Fake, FakeViewModel>(expected);

            await _handler.Handle(new SaveFakeCommand
            {
                Fake = expected
            });

            RepositoryMock.VerifyAll();
        }
예제 #19
0
        public void SetPropertyChanged(string value)
        {
            string actual = null;
            var    vm     = new FakeViewModel();

            vm.PropertyChanged += (s, e) =>
            {
                actual = e.PropertyName;
            };

            vm.Value = value;

            Assert.IsNotNull(actual);
            Assert.AreEqual("Value", actual);
            Assert.AreEqual(value, vm.Value);
        }
예제 #20
0
        public void IUserInputBeforeClosedRequestScreenOpen_ShowScreenAndRunContinuation_ActiveItemSetToScreen()
        {
            var    currentlyOpenFakeScreen = new FakeViewModel();
            var    fakeScreenToOpen        = new FakeViewModel();
            Action continuation            = () => { };

            currentlyOpenFakeScreen.ContinueIfCanCloseAction += c => continuation = c;
            var screenHost = new ScreenHost();

            screenHost.ShowScreen(currentlyOpenFakeScreen);

            screenHost.ShowScreen(fakeScreenToOpen);
            continuation();

            Assert.Equal(fakeScreenToOpen, screenHost.ActiveItem);
        }
예제 #21
0
        public void RaisePropertyChanged()
        {
            var propName = "Value";

            string actual = null;
            var    vm     = new FakeViewModel();

            vm.PropertyChanged += (s, e) =>
            {
                actual = e.PropertyName;
            };

            vm.NotifyPropertyChanged(propName);

            Assert.IsNotNull(actual);
            Assert.AreEqual(propName, actual);
        }
예제 #22
0
        public async Task ResolveNamed()
        {
            var containerMock = new Mock <IMvvmContainer>();
            var viewName      = "FakeView";
            var view          = new ContentPage();

            containerMock.Setup(m => m.ResolveNamed(viewName, It.IsAny <TypedParameter>()))
            .Returns(view);
            var fakeViewModel = new FakeViewModel();

            containerMock.Setup(m => m.Resolve <FakeViewModel>())
            .Returns(fakeViewModel);
            var navigationMock = new Mock <INavigation>();

            var impl = new ViewModelNavigationImpl(containerMock.Object);

            navigationMock.Setup(m => m.PushAsync(view)).Returns(Task.FromResult(0));

            await impl.Navigate <FakeViewModel>(navigationMock.Object);

            navigationMock.Verify(m => m.PushAsync(view), Times.Once);
            containerMock.Verify(m => m.ResolveNamed(viewName, It.Is <IParameter[]>(parameters =>
                                                                                    parameters.Count(p => ((TypedParameter)p).Value == fakeViewModel) == 1)), Times.Once);
        }
예제 #23
0
        public void ViewModelTypeNotRegisteredReturnsNull(WindowLocator sut, FakeViewModel viewModel)
        {
            var actual = sut.CreateWindow(viewModel, null);

            Assert.Null(actual);
        }
예제 #24
0
 public void NullViewModelThrowsException(WindowLocator sut, FakeViewModel owner)
 {
     Assert.Throws <ArgumentNullException>(() => sut.CreateWindow(null, owner));
 }
 public ModelPropertyTests()
 {
     _viewModel = new FakeViewModel <string>("", WhenUpdated);
 }