Exemplo n.º 1
0
        private void _TestSimpleLink(PfcElementType inType, PfcElementType outType, string shouldBe)
        {
            string testName = "Simple link from " + inType.ToString() + " to " + outType.ToString();
            Model  model    = new Model(testName);

            ProcedureFunctionChart pfc = new ProcedureFunctionChart(model, "SFC 1", "", Guid.NewGuid());

            IPfcNode n0, n1;

            n0 = CreateNode(pfc, "Alice", inType);
            n1 = CreateNode(pfc, "Bob", outType);
            pfc.Bind(n0, n1);

            string structureString = PfcDiagnostics.GetStructure(pfc);

            Console.WriteLine("After a " + testName + ", structure is \r\n" + structureString);
            Assert.AreEqual(StripCRLF(structureString), StripCRLF(shouldBe), "Structure should have been\r\n" + shouldBe + "\r\nbut it was\r\n" + structureString + "\r\ninstead.");

            if (m_testSerializationToo)
            {
                _TestSerialization(pfc, shouldBe, testName);
            }
        }
Exemplo n.º 2
0
        private void _TestComplexLink(LinkSuperType superType, PfcElementType inType, PfcElementType outType, string shouldBe)
        {
            string testName = superType.ToString() + " from " + inType.ToString() + " to " + outType.ToString();
            Model  model    = new Model(testName);

            ProcedureFunctionChart pfc = new ProcedureFunctionChart(model, "SFC 1", "", Guid.NewGuid());

            IPfcNode n0, n1, n2, n3, n4;

            switch (superType)
            {
            case LinkSuperType.ParallelConvergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", inType);
                n2 = CreateNode(pfc, "Charley", inType);
                n3 = CreateNode(pfc, "David", inType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindParallelConvergent(new IPfcNode[] { n0, n1, n2, n3 }, n4);
                break;

            case LinkSuperType.SeriesConvergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", inType);
                n2 = CreateNode(pfc, "Charley", inType);
                n3 = CreateNode(pfc, "David", inType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindSeriesConvergent(new IPfcNode[] { n0, n1, n2, n3 }, n4);
                break;

            case LinkSuperType.ParallelDivergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", outType);
                n2 = CreateNode(pfc, "Charley", outType);
                n3 = CreateNode(pfc, "David", outType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindParallelDivergent(n0, new IPfcNode[] { n1, n2, n3, n4 });
                break;

            case LinkSuperType.SeriesDivergent:
                n0 = CreateNode(pfc, "Alice", inType);
                n1 = CreateNode(pfc, "Bob", outType);
                n2 = CreateNode(pfc, "Charley", outType);
                n3 = CreateNode(pfc, "David", outType);
                n4 = CreateNode(pfc, "Edna", outType);
                pfc.BindSeriesDivergent(n0, new IPfcNode[] { n1, n2, n3, n4 });
                break;

            default:
                break;
            }


            string structureString = PfcDiagnostics.GetStructure(pfc);

            Console.WriteLine("After a " + testName + ", structure is \r\n" + structureString);
            Assert.AreEqual(StripCRLF(structureString), StripCRLF(shouldBe), "Structure should have been\r\n" + shouldBe + "\r\nbut it was\r\n" + structureString + "\r\ninstead.");

            if (m_testSerializationToo)
            {
                _TestSerialization(pfc, shouldBe, testName);
            }
        }