public void VerifyProperties() { var vm = new DiagramControlContextMenuViewModel { Behavior = this.behavior.Object }; Assert.IsNotEmpty(vm.ContextMenu); Assert.AreEqual(5, vm.ContextMenu.Count); Assert.AreEqual(6, vm.ContextMenu.OfType <BarSubItem>().SelectMany(x => x.Items).Count()); Assert.AreEqual(12, vm.ContextMenu.OfType <BarSubItem>().SelectMany(x => x.Items.OfType <BarSubItem>().SelectMany(s => s.Items)).Count()); Assert.IsNotNull(vm.Behavior); Assert.IsNotNull(vm.IsolateCommand); Assert.IsNotNull(vm.ApplyTreeViewLayoutRightToLeft); Assert.IsNotNull(vm.ApplyTreeViewLayoutLeftToRight); Assert.IsNotNull(vm.ApplyTreeViewLayoutBottomToTop); Assert.IsNotNull(vm.ApplyTreeViewLayoutTopToBottom); Assert.IsNotNull(vm.ApplyFugiyamaLayoutRightToLeft); Assert.IsNotNull(vm.ApplyFugiyamaLayoutLeftToRight); Assert.IsNotNull(vm.ApplyFugiyamaLayoutTopToBottom); Assert.IsNotNull(vm.ApplyFugiyamaLayoutBottomToTop); Assert.IsNotNull(vm.ApplyTipOverLayoutLeftToRight); Assert.IsNotNull(vm.ApplyTipOverLayoutRightToLeft); Assert.IsNotNull(vm.ApplyMindMapLayoutBottomToTop); Assert.IsNotNull(vm.ApplyMindMapLayoutLeftToRight); Assert.IsNotNull(vm.ApplyCircularLayout); Assert.IsNotNull(vm.ApplyOrganisationalChartLayout); Assert.IsNull(vm.HoveredElement); }
public void VerifyApplyLayout() { var vm = new DiagramControlContextMenuViewModel { Behavior = this.behavior.Object }; vm.ApplyTreeViewLayoutRightToLeft.Execute(null); this.behavior.Verify(x => x.ApplySpecifiedLayout(LayoutEnumeration.TreeView, LayoutDirection.RightToLeft), Times.Once); vm.ApplyFugiyamaLayoutBottomToTop.Execute(null); this.behavior.Verify(x => x.ApplySpecifiedLayout(LayoutEnumeration.Fugiyama, Direction.Up), Times.Once); vm.ApplyCircularLayout.Execute(null); this.behavior.Verify(x => x.ApplySpecifiedLayout(LayoutEnumeration.Circular), Times.Once); }
public void VerifyExportCommand() { var vm = new DiagramControlContextMenuViewModel { Behavior = this.behavior.Object }; Assert.IsTrue(vm.ContextMenu.Any()); Assert.IsTrue(vm.ExportGraphAsPdf.CanExecute(null)); Assert.IsTrue(vm.ExportGraphAsJpg.CanExecute(null)); vm.ExportGraphAsJpg.Execute(null); vm.ExportGraphAsPdf.Execute(null); this.behavior.Verify(x => x.ExportGraph(DiagramExportFormat.JPEG), Times.Once); this.behavior.Verify(x => x.ExportGraph(DiagramExportFormat.PDF), Times.Once); }
public void VerifyIsolation() { this.behavior.Setup(x => x.ExitIsolation()); this.behavior.Setup(x => x.Isolate()).Returns(false); var vm = new DiagramControlContextMenuViewModel { Behavior = this.behavior.Object }; vm.HoveredElement = null; Assert.IsFalse(vm.IsolateCommand.CanExecute(null)); vm.HoveredElement = new GraphElementViewModel(new NestedElement() { RootElement = new ElementDefinition(), ElementUsage = { new ElementUsage() { Container = new ElementDefinition() { Owner = new DomainOfExpertise() }, Owner = new DomainOfExpertise(), ElementDefinition = new ElementDefinition() } } }); Assert.IsTrue(vm.IsolateCommand.CanExecute(null)); vm.HoveredElement = null; Assert.IsFalse(vm.IsolateCommand.CanExecute(null)); Assert.IsFalse(vm.CanExitIsolation); vm.IsolateCommand.Execute(null); Assert.IsFalse(vm.CanExitIsolation); this.behavior.Setup(x => x.Isolate()).Returns(true); vm.IsolateCommand.Execute(null); Assert.IsTrue(vm.CanExitIsolation); vm.IsolateCommand.Execute(null); Assert.IsTrue(vm.CanExitIsolation); vm.ExitIsolationCommand.Execute(null); Assert.IsFalse(vm.CanExitIsolation); Assert.IsFalse(vm.ExitIsolationCommand.CanExecute(null)); this.behavior.Verify(x => x.Isolate(), Times.Exactly(3)); this.behavior.Verify(x => x.ExitIsolation(), Times.Once); }