public void SetTitle_ToolView_TitleSet() { // Setup const string titleToSet = "Random title"; var testView = new TestView(); using (var avalonDockViewHost = new AvalonDockViewHost()) { avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left, string.Empty, string.Empty, null); // Precondition Assert.IsFalse(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); // Call avalonDockViewHost.SetTitle(testView, titleToSet); // Assert Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet(avalonDockViewHost, testView, titleToSet)); } }
public void AddToolView_WithAllParameters_ViewAddedWithExpectedProperties(ToolViewLocation toolViewLocation) { // Setup using (var avalonDockViewHost = new AvalonDockViewHost()) { const string title = "Random title"; const string symbol = "Random symbol"; var fontFamily = new FontFamily(); var testView = new TestView(); // Call avalonDockViewHost.AddToolView(testView, toolViewLocation, title, symbol, fontFamily); // Assert CustomLayoutAnchorable layoutAnchorable = GetLayoutAnchorable(avalonDockViewHost, testView, toolViewLocation); Assert.AreEqual(title, layoutAnchorable.Title); Assert.AreEqual(symbol, layoutAnchorable.Symbol); Assert.AreSame(fontFamily, layoutAnchorable.FontFamily); } }
public void AddDocumentView_WithAllParameters_ViewAddedWithExpectedProperties() { // Setup using (var avalonDockViewHost = new AvalonDockViewHost()) { const string title = "Random title"; const string symbol = "Random symbol"; var fontFamily = new FontFamily(); var testView = new TestView(); // Call avalonDockViewHost.AddDocumentView(testView, title, symbol, fontFamily); // Assert CustomLayoutDocument layoutDocument = GetLayoutDocument(avalonDockViewHost, testView); Assert.AreEqual(title, layoutDocument.Title); Assert.AreEqual(symbol, layoutDocument.Symbol); Assert.AreSame(fontFamily, layoutDocument.FontFamily); } }
public void Remove_ToolViewInViewHostWithMultipleOtherViews_ActiveDocumentViewNotAffectedAndNoActiveViewEventsFired() { // Setup var testView1 = new TestView(); var testView2 = new TestView(); var testView3 = new TestView(); var testView4 = new TestView(); var testView5 = new TestView(); var activeDocumentViewChangingCounter = 0; var activeDocumentViewChangedCounter = 0; var activeViewChangedCounter = 0; using (var avalonDockViewHost = new AvalonDockViewHost()) { avalonDockViewHost.AddDocumentView(testView1, string.Empty, string.Empty, null); avalonDockViewHost.AddDocumentView(testView2, string.Empty, string.Empty, null); avalonDockViewHost.AddDocumentView(testView3, string.Empty, string.Empty, null); avalonDockViewHost.AddDocumentView(testView4, string.Empty, string.Empty, null); avalonDockViewHost.AddToolView(testView5, ToolViewLocation.Left, string.Empty, string.Empty, null); SetActiveView(avalonDockViewHost, testView3); SetActiveView(avalonDockViewHost, testView5); // Precondition Assert.AreSame(testView3, avalonDockViewHost.ActiveDocumentView); avalonDockViewHost.ActiveDocumentViewChanging += (sender, args) => activeDocumentViewChangingCounter++; avalonDockViewHost.ActiveDocumentViewChanged += (sender, args) => activeDocumentViewChangedCounter++; avalonDockViewHost.ActiveViewChanged += (sender, args) => activeViewChangedCounter++; // Call avalonDockViewHost.Remove(testView5); // Assert Assert.AreEqual(0, activeDocumentViewChangingCounter); Assert.AreEqual(0, activeDocumentViewChangedCounter); Assert.AreEqual(0, activeViewChangedCounter); Assert.AreSame(testView3, avalonDockViewHost.ActiveDocumentView); } }
public void Remove_ToolView_ViewClosedEventsFired() { // Setup var testView = new TestView(); var viewClosedCounter = 0; using (var avalonDockViewHost = new AvalonDockViewHost()) { avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left, string.Empty, string.Empty, null); avalonDockViewHost.ViewClosed += (sender, args) => { Assert.AreSame(testView, args.View); viewClosedCounter++; }; // Call avalonDockViewHost.Remove(testView); // Assert Assert.AreEqual(1, viewClosedCounter); } }
public void AddToolView_TestViews_ViewAddedAndViewOpenedEventFired(ToolViewLocation toolViewLocation) { // Setup var testView = new TestView(); IEnumerable <ToolViewLocation> otherToolViewLocations = Enum.GetValues(typeof(ToolViewLocation)) .Cast <ToolViewLocation>() .Except(new[] { toolViewLocation }); using (var avalonDockViewHost = new AvalonDockViewHost()) { var viewOpenedCounter = 0; avalonDockViewHost.ViewOpened += (sender, args) => { Assert.AreSame(testView, args.View); viewOpenedCounter++; }; // Call avalonDockViewHost.AddToolView(testView, toolViewLocation, string.Empty, string.Empty, null); // Assert CollectionAssert.AreEqual( new[] { testView }, avalonDockViewHost.ToolViews); Assert.IsTrue(IsToolViewPresent(avalonDockViewHost, testView, toolViewLocation)); Assert.IsFalse(otherToolViewLocations.Any(tvl => IsToolViewPresent(avalonDockViewHost, testView, tvl))); Assert.AreEqual(1, viewOpenedCounter); } }
public void OpenViewForData_DataHasSingleMatchOnBaseType_ReturnTrueAndAddToViewHost() { // Setup TestView view = null; var mocks = new MockRepository(); var dialogParent = mocks.Stub <IWin32Window>(); var viewHost = mocks.StrictMock <IViewHost>(); const string viewName = "<cool view name>"; viewHost.Stub(vh => vh.ViewClosed += null).IgnoreArguments(); viewHost.Stub(vh => vh.ViewClosed -= null).IgnoreArguments(); viewHost.Stub(vh => vh.DocumentViews).Return(new IView[0]); viewHost.Expect(vm => vm.AddDocumentView(Arg <TestView> .Is.NotNull, Arg <string> .Is.Equal(viewName), Arg <string> .Is.Null, Arg <FontFamily> .Is.Null)) .WhenCalled(invocation => { view = invocation.Arguments[0] as TestView; }); mocks.ReplayAll(); var data = new InheritedFromA(); var afterCreateCalled = false; var viewInfos = new ViewInfo[] { new ViewInfo <DocumentViewControllerTest, TestView>(), new ViewInfo <A, TestView> { AfterCreate = (v, o) => { Assert.IsInstanceOf <TestView>(v); Assert.AreSame(data, o); afterCreateCalled = true; }, GetViewName = (v, o) => { Assert.IsInstanceOf <TestView>(v); Assert.AreSame(data, o); return(viewName); } }, new ViewInfo <int, TestView>() }; using (var documentViewController = new DocumentViewController(viewHost, viewInfos, dialogParent)) { // Call bool result = documentViewController.OpenViewForData(data); // Assert Assert.IsTrue(result); Assert.AreEqual(data, view.Data); Assert.IsTrue(afterCreateCalled); } mocks.VerifyAll(); }