public void toggle_button_is_bound_to_property_listens_to_property_changed_events() { // arrange //Open new view to create a viewmodel for view testAddInBase.TestAddin.OnStartup(); var viewInstance = new TestView { Context = new TestWindowContext() }; viewProvider.NewView += Raise.EventWith(viewProvider, new NewViewEventArgs( viewInstance, viewInstance.Context, TestRibbonTypes.RibbonType1.GetEnumDescription())); var ribbon = Substitute.For <IRibbonUI>(); ribbonFactoryUnderTest.Ribbon_Load(ribbon); // act viewModelFactory.ViewModels.Single().OnPropertyChanged(new PropertyChangedEventArgs("PanelShown")); // assert ribbon.Received().InvalidateControl("testTogglePanelButton"); }
public void toggle_button_is_bound_to_property_get() { // arrange testAddInBase.TestAddin.OnStartup(); var processedRibbon = ribbonFactoryUnderTest.GetCustomUI(TestRibbonTypes.RibbonType1.GetEnumDescription()); //Open new view to create a viewmodel for view var viewInstance = new TestView { Context = new TestWindowContext() }; viewProvider.NewView += Raise.EventWith(viewProvider, new NewViewEventArgs( viewInstance, viewInstance.Context, TestRibbonTypes.RibbonType1.GetEnumDescription())); viewModelFactory.ViewModels.Single().PanelShown = true; var toggleButtonTag = GetTag(processedRibbon, "testTogglePanelButton"); // act var ribbonControl = GetRibbonControl("testTogglePanelButton", toggleButtonTag, viewInstance); var isPressed = ribbonFactoryUnderTest.GetPressed(ribbonControl); // assert Assert.True(isPressed); }
public void new_window_with_different_context_does_not_create_new_viewmodel() { // arrange testAddInBase.TestAddin.OnStartup(); //Open new view to create a viewmodel for view var viewInstance = new TestView { Context = new TestWindowContext() }; var view2Instance = new TestView { Context = new TestWindowContext() }; // act var newViewEventArgs = new NewViewEventArgs(viewInstance, viewInstance.Context, TestRibbonTypes.RibbonType1.GetEnumDescription()); var viewEventArgs = new NewViewEventArgs(view2Instance, view2Instance.Context, TestRibbonTypes.RibbonType1.GetEnumDescription()); viewProvider.NewView += Raise.EventWith(viewProvider, newViewEventArgs); viewProvider.NewView += Raise.EventWith(viewProvider, viewEventArgs); // assert Assert.Equal(2, viewModelFactory.ViewModels.Count); }