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); }
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); }
public void IUserInputBeforeClosedRequestScreenOpen_InteractivelyCloseAllScreens_ActiveItemStillIUserInputBeforeClosedRequestScreen() { var currentlyOpenFakeScreen = new FakeViewModel(); var screenHost = new ScreenHost(); screenHost.ShowScreen(currentlyOpenFakeScreen); screenHost.InteractivelyCloseAllScreens(() => { }); Assert.Equal(currentlyOpenFakeScreen, screenHost.ActiveItem); }
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); }
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); }
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); }
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); }
public void CanNavigateToNewViewWithViewModel() { _uiTestHelper.ExecuteOnUIThread(() => { // Prepare var fakeViewModel = new FakeViewModel(); // Act var expectedViewInfo = _navigationManagerImpl.NavigateTo("view1", fakeViewModel); // Verify Assert.AreSame(expectedViewInfo.ViewInstance.DataContext, fakeViewModel); }); }
public void CanSupportViewKeyAwareViewModel() { _uiTestHelper.ExecuteOnUIThread(() => { // Prepare var fakeViewKeyAwareViewModel = new FakeViewModel(); // Act _navigationManagerImpl.NavigateTo("view1", fakeViewKeyAwareViewModel); // Verify Assert.AreEqual("view1", fakeViewKeyAwareViewModel.ViewInstanceKey); }); }
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); }
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); }); }
public async Task ShouldSaveModel() { var expected = new FakeViewModel { Id = Guid.NewGuid() }; SetupCreateOrUpdate <Fake, FakeViewModel>(expected); await _handler.Handle(new SaveFakeCommand { Fake = expected }); RepositoryMock.VerifyAll(); }
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); }
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); }
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); }
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); }
public void ViewModelTypeNotRegisteredReturnsNull(WindowLocator sut, FakeViewModel viewModel) { var actual = sut.CreateWindow(viewModel, null); Assert.Null(actual); }
public void NullViewModelThrowsException(WindowLocator sut, FakeViewModel owner) { Assert.Throws <ArgumentNullException>(() => sut.CreateWindow(null, owner)); }
public ModelPropertyTests() { _viewModel = new FakeViewModel <string>("", WhenUpdated); }