public void Context() { _view = ViewMock.ObservePartial(new ViewModel { Name = "One" }) .WithProperty(vm => vm.Name); }
public void GetViewTest() { IView view = new ViewMock(); DummyViewModel viewModel = new DummyViewModel(view); Assert.AreEqual(view, viewModel.View); }
public void ProviderShouldUpdateCloseCommandToGoBack() { ViewPageMappingProvider.FindMappingForView = (type, b) => PageMapping; var testView = new ViewMock(); var viewModel = GetViewModel <NavigableViewModelMock>(); testView.DataContext = viewModel; viewModel.CloseCommand.ShouldBeNull(); NavigationService.OnNavigated(new NavigationEventArgsMock(testView, NavigationMode.New)); viewModel.CloseCommand.CanExecute(null).ShouldBeFalse(); NavigationService.CanClose = (model, context) => true; viewModel.CloseCommand.CanExecute(null).ShouldBeTrue(); bool isInvoked = false; NavigationService.TryClose = (m, c) => { m.ShouldEqual(viewModel); isInvoked = true; return(true); }; viewModel.CloseCommand.Execute(null); isInvoked.ShouldBeTrue(); }
public void OnInitialized_SetPage() { var view = new ViewMock(); var app = new PrismApplicationMock(view); Assert.True(app.Initialized); Assert.NotNull(Application.Current.MainPage); Assert.Same(view, Application.Current.MainPage); }
public void OnInitialized_SetPage() { Page view = null; var app = CreateMockApplication(() => view = new ViewMock()); Assert.True(app.Initialized); Assert.NotNull(Application.Current.MainPage); Assert.Same(view, Application.Current.MainPage); }
public void InstructsViewToExpandTreeViewWhenUserGroupsHaveBeenReceived() { RequestDispatcherStub.SetResponsesToReturn(new GetAllUserGroupsResponse { UserGroups = new[] { new UserGroupDto() } }); Presenter.Initialize(); RequestDispatcherStub.ReturnResponses(); ViewMock.Verify(v => v.ExpandTreeView()); }
public void Context() { var viewModel = new ViewModel { Name = "Default" }; _view = ViewMock.Observe(viewModel); viewModel.Name = "Not Notified"; }
public void It_should_display_the_new_correct_name_in_the_view() { var viewModel = new ViewModel { Name = "Default" }; var view = ViewMock.Observe(viewModel); viewModel.ChangeNameAndNotify("Notified Name"); Assert.That(view.Property(vm => vm.Name), Is.EqualTo("Notified Name")); }
public void HidesAddNewButtonOnViewIfUserDoesntHaveRequiredPermission() { RequestDispatcherStub.SetResponsesToReturn(new CheckPermissionsResponse { AuthorizationResults = new Dictionary <Guid, bool> { { Permissions.CreateUserGroup, false } } }); Presenter.Initialize(); RequestDispatcherStub.ReturnResponses(); ViewMock.Verify(v => v.HideAddNewButton()); }
public void It_should_display_the_new_updated_name_in_the_view() { var viewModel = new ViewModel { Name = "Default" }; var view = ViewMock.Observe(viewModel); viewModel.Name = "Notified Name"; viewModel.NotifyWithEmptyString(); Assert.That(view.Property(vm => vm.Name), Is.EqualTo("Notified Name")); }
public void ResponsesReceived_ShowsTheView() { var suitableParents = new[] { new UserGroupDto { Id = Guid.NewGuid() } }; Presenter.Handle(new UserGroupNeedsToBeCreatedEvent()); RequestDispatcherStub.SetResponsesToReturn(new GetSuitableParentUserGroupsResponse { SuitableParentUserGroups = suitableParents }); RequestDispatcherStub.ReturnResponses(); ViewMock.Verify(v => v.Show()); }
public void SelectsItemInTreeViewIfItsNewUserGroup() { var id = Guid.NewGuid(); HierarchicalUserGroupBindingModel hierarchicalUserGroupBindingModel = null; ViewMock.Setup(v => v.SelectItemInTreeView(It.IsAny <HierarchicalUserGroupBindingModel>())) .Callback(new Action <HierarchicalUserGroupBindingModel>(m => hierarchicalUserGroupBindingModel = m)); Presenter.Handle(new UserGroupChangedEvent { Id = id, IsNew = true }); Assert.AreEqual(id, hierarchicalUserGroupBindingModel.Id); }
public void ProviderShouldUpdateCanCloseMetadata() { ViewPageMappingProvider.FindMappingForView = (type, b) => PageMapping; var testView = new ViewMock(); var viewModel = GetViewModel <NavigableViewModelMock>(); testView.DataContext = viewModel; viewModel.Settings.Metadata.GetData(ViewModelConstants.CanCloseHandler).ShouldBeNull(); NavigationService.OnNavigated(new NavigationEventArgsMock(testView, NavigationMode.New)); viewModel.Settings.Metadata.GetData(ViewModelConstants.CanCloseHandler).Invoke(viewModel, null).ShouldBeFalse(); NavigationService.CanClose = (model, context) => true; viewModel.Settings.Metadata.GetData(ViewModelConstants.CanCloseHandler).Invoke(viewModel, null).ShouldBeTrue(); }
public void ResponsesReceived_DoesNotTellViewToPreventModificationIfUserHasPermission() { Presenter.Handle(new UserGroupSelectedEvent(Guid.NewGuid())); RequestDispatcherStub.SetResponsesToReturn(new GetUserGroupResponse(), new GetSuitableParentUserGroupsResponse { SuitableParentUserGroups = new UserGroupDto[0] }, new CheckPermissionsResponse { AuthorizationResults = new Dictionary <Guid, bool> { { Permissions.DeleteUserGroup, true }, { Permissions.EditUserGroup, true } } }); RequestDispatcherStub.ReturnResponses(); ViewMock.Verify(v => v.PreventModification(), Times.Never()); }
public virtual ActionResult ViewEntry(string viewName) { viewName = Server.UrlDecode(viewName); var viewPosition = new ViewPosition() { LayoutPositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5), ViewName = viewName, PagePositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5) }; //pageUrl: product/detail/product1 var rawPage = new Page(Site, "____VisitViewPage_____") { IsDummy = false }; rawPage.PagePositions.Add(viewPosition); var requestUrl = "/"; var pageRequestContext = new PageRequestContext(this.ControllerContext, FrontHttpRequest.RawSite, FrontHttpRequest.Site, rawPage, rawPage, FrontHttpRequest.RequestChannel, requestUrl); Page_Context.Current.InitContext(pageRequestContext, ControllerContext); var actionResult = Page_Context.Current.ExecutePlugins(); if (actionResult != null) { return(actionResult); } Page_Context.Current.ExecuteDataRules(); var viewMock = new ViewMock() { ViewData = new ViewDataDictionary(ViewData) }; ViewContext viewContext = new ViewContext(this.ControllerContext, viewMock, ViewData, this.TempData, Response.Output); HtmlHelper html = new HtmlHelper(viewContext, viewMock); return(Content(html.FrontHtml().RenderView(viewPosition).ToString())); }
public void ProviderShouldCloseViewModel() { ViewPageMappingProvider.FindMappingForView = (type, b) => PageMapping; var testView = new ViewMock(); var viewModel = GetViewModel <NavigableViewModelMock>(); testView.DataContext = viewModel; NavigationService.OnNavigated(new NavigationEventArgsMock(testView, NavigationMode.New)); bool isInvoked = false; NavigationService.CanClose = (model, context) => true; NavigationService.TryClose = (m, c) => { m.ShouldEqual(viewModel); isInvoked = true; return(true); }; NavigationProvider.TryCloseAsync(new DataContext(NavigationConstants.ViewModel.ToValue(viewModel))); isInvoked.ShouldBeTrue(); }
public void Initialize_HidesTheView() { Presenter.Initialize(); ViewMock.Verify(v => v.Hide()); }
public virtual ActionResult ViewEntry(string viewName) { viewName = Server.UrlDecode(viewName); var viewPosition = new ViewPosition() { LayoutPositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5), ViewName = viewName, PagePositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5) }; //pageUrl: product/detail/product1 var rawPage = new Page(Site, "____VisitViewPage_____") { IsDummy = false }; rawPage.PagePositions.Add(viewPosition); var requestUrl = ""; var pageRequestContext = new PageRequestContext(this.ControllerContext, FrontHttpRequest.RawSite, FrontHttpRequest.Site, rawPage, rawPage, FrontHttpRequest.RequestChannel, requestUrl); Page_Context.Current.InitContext(pageRequestContext, ControllerContext); var actionResult = Page_Context.Current.ExecutePlugins(); if (actionResult != null) { return actionResult; } Page_Context.Current.ExecuteDataRules(); var viewMock = new ViewMock() { ViewData = new ViewDataDictionary(ViewData) }; ViewContext viewContext = new ViewContext(this.ControllerContext, viewMock, ViewData, this.TempData, Response.Output); HtmlHelper html = new HtmlHelper(viewContext, viewMock); return Content(html.FrontHtml().RenderView(viewPosition).ToString()); }
public void TellsViewToEnableEverything() { Presenter.Handle(new UserGroupSelectedEvent(Guid.NewGuid())); ViewMock.Verify(v => v.EnableEverything()); }
public void Context() { _view = ViewMock.Observe(new ViewModel { Name = "One" }); }
public void TellsViewToPreventDeletion() { Presenter.Handle(new UserGroupNeedsToBeCreatedEvent()); ViewMock.Verify(v => v.PreventDeletion()); }