public void Defect_IDE_1556()
        {
            // Load the LinesToGrid.bin file. It should give exception, but no crash

            Assert.Throws<InvalidDataException>(() =>
            {
                IStorage s2 = new FileStorage();
                string testPath = "..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\";
                string filePath = testPath + "LinesToGrid.bin";
                ((FileStorage)s2).Load(filePath);

                GraphController graphController = new GraphController(null, filePath);

                Assert.AreEqual(0, graphController.GetVisualNodes().Count);
            });
        }
        public void Defect_IDE_1705()
        {
            // create six codeblock nodes and connect it to a function node with six slots
            // save and load it
            //IDE-1213
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "Defect_1705.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(3, graphController.GetVisualNodes().Count);

            //IVisualNode node01 = graphController.GetVisualNode(0x10000002);// Code Block Node
            //Assert.AreEqual("1", node01.PreviewValue);
        }
        public void Defect_IDE_1619()
        {
            // Steps as in defect : http://adsk-oss.myjetbrains.com/youtrack/issue/IDE-1619
            // Load the Defect_IDE_2285.bin file
            // Then connect the '0' to the Z input of the Point and verify the Arc node now shows the geometric output
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "Defect_IDE_1619.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController controller = new GraphController(null, filePath);

            string commands = @"ClearSelection
            ClearSelection
            MouseDown|e:System.Windows.Input.MouseButton,Left|u:0x10000009|e:DesignScriptStudio.Graph.Core.NodePart,OutputSlot|i:0|e:System.Windows.Input.ModifierKeys,None
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000009|e:DesignScriptStudio.Graph.Core.NodePart,OutputSlot|i:0|e:System.Windows.Input.ModifierKeys,None
            BeginDrag|e:System.Windows.Input.MouseButton,Left|u:0x10000009|e:DesignScriptStudio.Graph.Core.NodePart,OutputSlot|i:0|e:System.Windows.Input.ModifierKeys,None|d:15296.25|d:15054.83333333
            EndDrag|e:System.Windows.Input.MouseButton,Left|u:0x1000000a|e:DesignScriptStudio.Graph.Core.NodePart,InputSlot|i:2|e:System.Windows.Input.ModifierKeys,None|d:15380.58333333|d:15070.83333333
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x1000000a|e:DesignScriptStudio.Graph.Core.NodePart,InputSlot|i:2|e:System.Windows.Input.ModifierKeys,None
            MouseDown|e:System.Windows.Input.MouseButton,Left|u:0xffffffff|e:DesignScriptStudio.Graph.Core.NodePart,None|i:-1|e:System.Windows.Input.ModifierKeys,None
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0xffffffff|e:DesignScriptStudio.Graph.Core.NodePart,None|i:-1|e:System.Windows.Input.ModifierKeys,None";

            bool result00 = controller.RunCommands(commands);
            Assert.AreEqual(true, result00);

            VisualNode node;

            node = (VisualNode)controller.GetVisualNode(0x1000000b);
            Assert.AreEqual(true, node.NodeStates.HasFlag(States.GeometryPreview));
        }
        public void Defect_IDE_1744()
        {
            // create six codeblock nodes and connect it to a function node with six slots
            // save and load it
            //IDE-1213
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "AdditionOfNumber_FromExternalDS.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(2, graphController.GetVisualNodes().Count);
        }
        public void TestLoadingSavingFile00()
        {
            try
            {
                IStorage s1 = new FileStorage();
                IStorage s2 = new FileStorage();

                string str = "World Hello";
                byte[] bytes = Encoding.ASCII.GetBytes(str);
                ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', ' ', ' ', ' ');

                s1.WriteBytes(signature, bytes);
                s1.WriteInteger(signature, 24);
                s1.WriteUnsignedInteger(signature, 2147483648);
                s1.WriteLong(signature, 3000000000);
                s1.WriteUnsignedLong(signature, 9223372036854775808);
                s1.WriteBoolean(signature, true);
                s1.WriteDouble(signature, 1.7);
                s1.WriteString(signature, "Hello World");

                string filePath = Path.GetTempPath() + "test.bin";
                ((FileStorage)s1).Save(filePath);
                ((FileStorage)s2).Load(filePath);

                byte[] a = s2.ReadBytes(signature);
                int b = s2.ReadInteger(signature);
                uint c = s2.ReadUnsignedInteger(signature);
                long d = s2.ReadLong(signature);
                ulong e = s2.ReadUnsignedLong(signature);
                bool f = s2.ReadBoolean(signature);
                double g = s2.ReadDouble(signature);
                string h = s2.ReadString(signature);

                Assert.AreEqual(bytes, a);
                Assert.AreEqual(24, b);
                Assert.AreEqual(2147483648, c);
                Assert.AreEqual(3000000000, d);
                Assert.AreEqual(9223372036854775808, e);
                Assert.AreEqual(true, f);
                Assert.AreEqual(1.7, g);
                Assert.AreEqual("Hello World", h);
            }
            finally
            {
                File.Delete(Path.GetTempPath() + "test.bin");
            }
        }
        public void TestLoadingSavedFile06()
        {
            // create six codeblock nodes and connect it to a function node with six slots
            // save and load it
            //IDE-1213
            IStorage s2 = new FileStorage();
            string testPath = "..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\";
            string filePath = testPath + "sixslots.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(7, graphController.GetVisualNodes().Count);
            IVisualNode node11 = graphController.GetVisualNodes()[0];
            Assert.AreEqual(NodeType.CodeBlock, node11.VisualType);
            IVisualNode node12 = graphController.GetVisualNodes()[1];
            Assert.AreEqual(NodeType.CodeBlock, node12.VisualType);
            IVisualNode node13 = graphController.GetVisualNodes()[2];
            Assert.AreEqual(NodeType.CodeBlock, node13.VisualType);
            IVisualNode node14 = graphController.GetVisualNodes()[3];
            Assert.AreEqual(NodeType.CodeBlock, node14.VisualType);
            IVisualNode node15 = graphController.GetVisualNodes()[4];
            Assert.AreEqual(NodeType.CodeBlock, node15.VisualType);
            IVisualNode node16 = graphController.GetVisualNodes()[5];
            Assert.AreEqual(NodeType.CodeBlock, node16.VisualType);
            IVisualNode node17 = graphController.GetVisualNodes()[6];
            Assert.AreEqual(NodeType.Function, node17.VisualType);
            IVisualEdge edge01 = graphController.GetVisualEdge(0x60000001);
            IVisualEdge edge02 = graphController.GetVisualEdge(0x60000002);
            IVisualEdge edge03 = graphController.GetVisualEdge(0x60000003);
            IVisualEdge edge04 = graphController.GetVisualEdge(0x60000004);
            IVisualEdge edge05 = graphController.GetVisualEdge(0x60000005);
            IVisualEdge edge06 = graphController.GetVisualEdge(0x60000006);
        }
        public void TestLoadingSavedFile02()
        {
            // create three codeblock nodes and add them and connect to the functiona and the to the identifier
            // save and load it
            //IDE-1213
            IStorage s2 = new FileStorage();
            string testPath = "..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\";
            string filePath = testPath + "threeslots.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(5, graphController.GetVisualNodes().Count);
            IVisualNode node11 = graphController.GetVisualNodes()[0];
            Assert.AreEqual(NodeType.CodeBlock, node11.VisualType);
            IVisualNode node12 = graphController.GetVisualNodes()[1];
            Assert.AreEqual(NodeType.CodeBlock, node12.VisualType);
            IVisualNode node13 = graphController.GetVisualNodes()[2];
            Assert.AreEqual(NodeType.CodeBlock, node13.VisualType);
            IVisualNode node14 = graphController.GetVisualNodes()[3];
            Assert.AreEqual(NodeType.Function, node14.VisualType);
            IVisualNode node15 = graphController.GetVisualNodes()[4];
            Assert.AreEqual(NodeType.Identifier, node15.VisualType);
            IVisualEdge edge01 = graphController.GetVisualEdge(0x60000001);
            IVisualEdge edge02 = graphController.GetVisualEdge(0x60000002);
            IVisualEdge edge03 = graphController.GetVisualEdge(0x60000003);
            IVisualEdge edge04 = graphController.GetVisualEdge(0x60000004);
        }
        public void TestLoadingSavedFile03()
        {
            // create a codeblock and connect it to a driver
            // save and load it
            //IDE-1213
            IStorage s2 = new FileStorage();
            string testPath = "..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\";
            string filePath = testPath + "driver.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(2, graphController.GetVisualNodes().Count);
            IVisualNode node11 = graphController.GetVisualNodes()[0];
            Assert.AreEqual(NodeType.Driver, node11.VisualType);
            IVisualNode node12 = graphController.GetVisualNodes()[1];
            Assert.AreEqual(NodeType.Identifier, node12.VisualType);
            IVisualEdge edge01 = graphController.GetVisualEdge(0x60000001);
        }
        public void TestLoadingNonExistingFile()
        {
            IStorage storage = new FileStorage();
            string filePath = Path.GetTempPath() + "test.bin";

            Assert.Throws<FileNotFoundException>(() =>
            {
                ((FileStorage)storage).Load(filePath);
            });
        }
Beispiel #10
0
        public void TestLoadingSavedFile00()
        {
            // IDE-1213
            // create two codeblock nodes and identifier and connect them
            // save and load it
            //
            IStorage s2 = new FileStorage();
            string testPath = "..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\";
            string filePath = testPath + "save.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(4, graphController.GetVisualNodes().Count);
            IVisualNode node11 = graphController.GetVisualNodes()[0];
            Assert.AreEqual(NodeType.CodeBlock, node11.VisualType);
            IVisualNode node12 = graphController.GetVisualNodes()[1];
            Assert.AreEqual(NodeType.CodeBlock, node12.VisualType);
            IVisualNode node13 = graphController.GetVisualNodes()[2];
            Assert.AreEqual(NodeType.Identifier, node13.VisualType);
            IVisualNode node14 = graphController.GetVisualNodes()[3];
            Assert.AreEqual(NodeType.Identifier, node14.VisualType);
            IVisualEdge edge01 = graphController.GetVisualEdge(0x60000001);
            IVisualEdge edge02 = graphController.GetVisualEdge(0x60000002);
        }
Beispiel #11
0
        public void Defect_IDE_2241()
        {
            // steps as per defect http://adsk-oss.myjetbrains.com/youtrack/issue/IDE-2241
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "Defect_IDE_2241.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            string commands = @"MouseDown|e:System.Windows.Input.MouseButton,Left|u:0x1000000f|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x1000000f|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None
            DeleteComponents
            CreateRadialMenu|e:DesignScriptStudio.Graph.Core.NodePart,NorthEast|u:0x1000000e
            CreateSubRadialMenu|i:1002
            CreateSubRadialMenu|i:1002
            SelectMenuItem|i:1002|d:16850.50647433|d:15341.08333333|u:0x1000000e|e:DesignScriptStudio.Graph.Core.NodePart,NorthEast
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000010|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None
            CreateRadialMenu|e:DesignScriptStudio.Graph.Core.NodePart,NorthEast|u:0x10000010
            CreateSubRadialMenu|i:1001
            CreateSubRadialMenu|i:1001
            SelectMenuItem|i:1001|d:16917.173141|d:15304.41666667|u:0x10000010|e:DesignScriptStudio.Graph.Core.NodePart,NorthEast
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000011|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None
            MouseDown|e:System.Windows.Input.MouseButton,Left|u:0x10000011|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None
            BeginDrag|e:System.Windows.Input.MouseButton,Left|u:0x10000011|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None|d:16930.50647433|d:15309.41666667
            EndDrag|e:System.Windows.Input.MouseButton,Left|u:0x10000011|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None|d:17103.83980766|d:15289.41666667
            MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000011|e:DesignScriptStudio.Graph.Core.NodePart,Caption|i:-1|e:System.Windows.Input.ModifierKeys,None";

            bool result = graphController.RunCommands(commands);
            Assert.AreEqual(true, result);

            Assert.AreEqual(11, graphController.GetVisualNodes().Count);
        }
Beispiel #12
0
        public void Defect_IDE_2225()
        {
            // steps as per defect http://adsk-oss.myjetbrains.com/youtrack/issue/IDE-2225
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "Defect_IDE_2225.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);
            Assert.AreEqual(6, graphController.GetVisualNodes().Count);

            // there should not be any errors
            ProtoCore.BuildStatus buildStatus = GraphToDSCompiler.GraphUtilities.BuildStatus;
            Assert.AreEqual(0, buildStatus.ErrorCount);
            Assert.AreEqual(0, buildStatus.WarningCount);

            IVisualNode node = graphController.GetVisualNode(0x10000003);
            // there should be no error/warning from this node
            Assert.AreEqual(String.Empty, node.ErrorMessage);
        }
Beispiel #13
0
        public void Defect_IDE_2053()
        {
            // steps as per defect http://adsk-oss.myjetbrains.com/youtrack/issue/IDE-2053
            IStorage s2 = new FileStorage();
            string testPath = Path.GetFullPath("..\\..\\..\\..\\Studio\\DesignScriptStudio.Tests\\UnitTests\\testfiles\\");
            string filePath = testPath + "class.bin";
            ((FileStorage)s2).Load(filePath);

            GraphController graphController = new GraphController(null, filePath);

            Assert.AreEqual(1, graphController.GetVisualNodes().Count);
        }
        private void SaveFileInternal(string filePath)
        {
            IStorage storage = new FileStorage();
            DataHeader header = new DataHeader();
            long initialPosition, currentPosition = 0;

            //Serialize states
            storage.Seek(header.HeaderSize, SeekOrigin.Current);
            initialPosition = storage.GetPosition();
            this.graphProperties.Serialize(storage);
            currentPosition = storage.GetPosition();
            header.DataSize = currentPosition - initialPosition;
            storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
            header.Serialize(storage);
            storage.Seek(header.DataSize, SeekOrigin.Current);

            //Serialize slots
            List<ISlot> slotList = new List<ISlot>(this.slotCollection.Values);
            storage.WriteInteger(FieldCode.SlotCount, slotList.Count);
            foreach (ISlot slot in slotList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                slot.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Serialize nodes
            List<IVisualNode> nodeList = new List<IVisualNode>(this.nodeCollection.Values);
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                node.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Serialize edges
            List<IVisualEdge> edgeList = this.edgeController.GetVisualEdges();
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                edge.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            ((FileStorage)storage).Save(filePath);
        }
        private void LoadFileInternal(string filePath)
        {
            FileStorage storage = new FileStorage();
            DataHeader header = new DataHeader();
            storage.Load(filePath);

            //Deserialize states
            header.Deserialize(storage);
            this.graphProperties.Deserialize(storage);

            foreach (string scriptPath in this.graphProperties.ImportedScripts)
            {
                CoreComponent.Instance.ImportAssembly(scriptPath, filePath, true);
            }

            //Deserialize slots
            int slotCount = storage.ReadInteger(FieldCode.SlotCount);
            for (int i = 0; i < slotCount; i++)
            {
                header.Deserialize(storage);
                ISlot slot = Slot.Create(this, storage);
                this.AddSlot(slot);
            }

            //Deserialize nodes
            int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
            for (int j = 0; j < nodeCount; j++)
            {
                header.Deserialize(storage);
                IVisualNode node = VisualNode.Create(this, storage);
                this.AddVisualNode(node);
            }

            //Deserialize edges
            int edgeCount = storage.ReadInteger(FieldCode.EdgeCount);
            for (int j = 0; j < edgeCount; j++)
            {
                header.Deserialize(storage);
                IVisualEdge edge = VisualEdge.Create(this.edgeController, storage);
                this.AddVisualEdge(edge);
            }

            //AuditLoadedGraph();

            // These calls internally figure out the type of id
            // it is meant for, and set the value accordingly.
            if (nodeCount > 0)
                this.idGenerator.SetStartId(this.nodeCollection.Keys.Max());
            if (slotCount > 0)
                this.idGenerator.SetStartId(this.slotCollection.Keys.Max());
            if (edgeCount > 0)
                this.idGenerator.SetStartId(this.edgeController.GetMaxEdgeId());
        }