Exemple #1
0
        public void KeepListStructureUpdatesPortViewCorrectly()
        {
            var openPath = System.IO.Path.Combine(GetTestDirectory(ExecutingDirectory), @"UI\keepListStructure.dyn");

            ViewModel.OpenCommand.Execute(openPath);
            var rankNode = this.Model.CurrentWorkspace.Nodes.Where(x => x.Name == "List.Rank").FirstOrDefault();

            Assert.NotNull(rankNode);
            Assert.AreEqual(4, this.Model.CurrentWorkspace.Nodes.Count());
            RunCurrentModel();

            var rank = rankNode.CachedValue.Data;

            Assert.AreEqual(2, rank);

            var addNode = this.Model.CurrentWorkspace.Nodes.Where(x => x.Name == "+").FirstOrDefault();

            Assert.NotNull(addNode);
            addNode.InPorts.First().KeepListStructure = true;

            RunCurrentModel();
            rank = rankNode.CachedValue.Data;
            Assert.AreEqual(3, rank);

            //find the nodeView that has the same dataContext as the addNode.
            Utility.DispatcherUtil.DoEvents();
            var nodeViews        = WpfUtilities.ChildrenOfType <NodeView>(View);
            var nodeViewModel    = ViewModel.CurrentSpaceViewModel.Nodes.Where(x => x.Id == addNode.GUID).FirstOrDefault();
            var matchingNodeView = nodeViews.Where(x => (x.DataContext as NodeViewModel).Id == nodeViewModel.Id).FirstOrDefault();

            Assert.NotNull(nodeViewModel);
            Assert.NotNull(matchingNodeView);

            //when keeplist structure is on highlight should be blue
            ItemsControl inputItemsControl = WpfUtilities.ChildrenOfType <ItemsControl>(matchingNodeView).Where(x => x.Name == "inputPortControl").FirstOrDefault();

            Assert.NotNull(inputItemsControl);

            var portViewModel = inputItemsControl.ItemsSource.OfType <PortViewModel>().FirstOrDefault();

            Assert.NotNull(portViewModel);

            var trueColor = SharedDictionaryManager.DynamoColorsAndBrushesDictionary["PortKeepListStructureBackground"] as SolidColorBrush;

            Assert.AreEqual(trueColor.Color, portViewModel.PortBackgroundColor.Color);

            //when keeplist structure is on text should start with @@.
            var spinner = WpfUtilities.ChildrenOfType <UseLevelSpinner>(matchingNodeView).FirstOrDefault();

            Assert.True(spinner.ContentText.StartsWith("@@"));
        }
        public void ClickingToCloseViewExtensionTabTest()
        {
            RaiseLoadedEvent(this.View);
            var extensionManager = View.viewExtensionManager;

            extensionManager.Add(viewExtension);
            // Open a graph which should bring up the Workspace References view extension window with one tab
            Open(@"pkgs\Dynamo Samples\extra\CustomRenderExample.dyn");
            Assert.AreEqual(1, View.ExtensionTabItems.Count);

            Utility.DispatcherUtil.DoEvents();
            View.CloseExtensionTab(WpfUtilities.ChildrenOfType <Button>(View.ExtensionTabItems.FirstOrDefault()).FirstOrDefault(), null);
            Assert.AreEqual(0, View.ExtensionTabItems.Count);
        }