public void PackagedNodeSearchElementLoadedType()
        {
            var category              = "abc.xyz.somepackage";
            var name                  = "My Node";
            var creationName          = "create abc xyz";
            var expectedQualifiedName = "pkg://abc.xyz.somepackage.My Node";
            var path                  = @"C:\temp\packages\test.dll";
            var moq = new Mock <TestNodeSearchElement>(category, name, ElementTypes.Packaged, path)
            {
                CallBase = true
            };
            var element = moq.Object;

            moq.Setup(e => e.CreationName).Returns(creationName);

            var provider = new NodeItemDataProvider(new NodeSearchModel());
            var item     = provider.CreateLoadedTypeItem <LoadedTypeItem>(element);

            Assert.AreEqual(expectedQualifiedName, item.fullyQualifiedName);
            Assert.AreEqual(creationName, item.contextData);
            Assert.AreEqual("abc, xyz, somepackage", item.keywords);

            var url = new IconUrl(new Uri(item.iconUrl));

            Assert.AreEqual("My%20Node.Small", url.Name);
            Assert.AreEqual(path, url.Path);
        }
        public void CustomNodePropertiesWindowValidateCategories()
        {
            // sample CN #1
            var CN1_Info = new CustomNodeInfo(
                Guid.NewGuid(),
                "category test node 1",
                "base.level1.level2.level3",
                "A node for testing CN dialog categories drop - down",
                @"C:\temp\category_test_node_1.dyf");

            // sample CN #2
            var CN2_Info = new CustomNodeInfo(
                Guid.NewGuid(),
                "category test node 2",
                "base.level1.level2.level3.level4.level5",
                "A node for testing CN dialog categories drop - down",
                @"C:\temp\category_test_node_2.dyf");

            var CN1_Mock = new Mock <ICustomNodeSource>();
            var CN2_Mock = new Mock <ICustomNodeSource>();

            var CN1_element = new CustomNodeSearchElement(CN1_Mock.Object, CN1_Info);
            var CN2_element = new CustomNodeSearchElement(CN2_Mock.Object, CN2_Info);

            var provider       = new NodeItemDataProvider(new NodeSearchModel());
            var CN1_LoadedType = provider.CreateLoadedTypeItem <LoadedTypeItem>(CN1_element);
            var CN2_LoadedType = provider.CreateLoadedTypeItem <LoadedTypeItem>(CN2_element);

            var elements = new NodeSearchElement[] { CN1_element, CN2_element };

            // Call function used to populate Add-ons categories drop-down in CN properties window
            List <string> addOnCategories = Dynamo.Controls.DynamoView.getUniqueAddOnCategories(elements).ToList();

            // Expected results
            var CN1_expectedQualifiedName = "dyf://base.level1.level2.level3.category test node 1";
            var CN2_expectedQualifiedName = "dyf://base.level1.level2.level3.level4.level5.category test node 2";

            // Expected unique categories that will be populated for the drop-down in the function above
            string[] expectedCategories = new string[]
            {
                "base",
                "base.level1",
                "base.level1.level2",
                "base.level1.level2.level3",
                "base.level1.level2.level3.level4",
                "base.level1.level2.level3.level4.level5"
                // Should not include node names at bottom levels
            };

            // Verify expected results
            Assert.AreEqual(CN1_expectedQualifiedName, CN1_LoadedType.fullyQualifiedName);
            Assert.AreEqual(CN2_expectedQualifiedName, CN2_LoadedType.fullyQualifiedName);
            Assert.AreEqual(addOnCategories.Count, expectedCategories.Length);

            for (int i = 0; i < addOnCategories.Count; i++)
            {
                Assert.AreEqual(addOnCategories[i], expectedCategories[i]);
            }
        }
        public void NodeSearchElementLoadedType()
        {
            var fullname                 = "abc.xyz.something";
            var creationName             = "create abc xyz";
            Mock <NodeSearchElement> moq = MockNodeSearchElement(fullname, creationName);
            var element = moq.Object;

            var provider = new NodeItemDataProvider(new NodeSearchModel());
            var item     = provider.CreateLoadedTypeItem <LoadedTypeItem>(element);

            Assert.AreEqual(fullname, item.fullyQualifiedName);
            Assert.AreEqual(creationName, item.contextData);
        }
Example #4
0
        public void NodeItemDataProvider()
        {
            var    provider = new NodeItemDataProvider(GetModel().SearchModel);
            var    request  = new Mock <IRequest>();
            string ext      = "txt";

            using (var stream = provider.GetResource(request.Object, out ext))
            {
                Assert.AreEqual("json", ext);
                Assert.IsNotNull(stream);
                var data = GetLoadedTypesFromJson(stream);
                Assert.IsNotNull(data);
                Assert.Less(0, data.loadedTypes.Count);
                data.loadedTypes.ForEach(e =>
                {
                    Assert.IsNotNullOrEmpty(e.contextData);
                    Assert.IsNotNullOrEmpty(e.fullyQualifiedName);
                    Assert.IsNotNullOrEmpty(e.iconUrl);
                    Assert.IsNotNullOrEmpty(e.itemType);
                });
            }
        }
        public void CustomNodeSearchElementLoadedType()
        {
            var category = "abc.xyz.somepackage";
            var name     = "My Node";
            var path     = @"C:\temp\xyz.dyf";
            var guid     = Guid.NewGuid();
            var info     = new CustomNodeInfo(guid, name, category, "some description", path);
            var expectedQualifiedName = "dyf://abc.xyz.somepackage.My Node";
            var moq     = new Mock <ICustomNodeSource>();
            var element = new CustomNodeSearchElement(moq.Object, info);

            var provider = new NodeItemDataProvider(new NodeSearchModel());
            var item     = provider.CreateLoadedTypeItem <LoadedTypeItem>(element);

            Assert.AreEqual(expectedQualifiedName, item.fullyQualifiedName);
            Assert.AreEqual(guid.ToString(), item.contextData);
            Assert.AreEqual(string.Empty, item.keywords);

            var url = new IconUrl(new Uri(item.iconUrl));

            Assert.AreEqual(IconUrl.DefaultIcon, url.Name);
            Assert.AreEqual(IconUrl.DefaultPath, url.Path);
        }