示例#1
0
        public void StatementRequiresOutputPort02()
        {
            var svs = new List <List <string> >()
            {
                new List <string>()
                {
                    "Apple", "Orange"
                },

                new List <string>()
                {
                    "Watermelon", "Grape", "HoneyDew"
                },

                new List <string>()
                {
                    "Lemon", "Apple"
                }
            };

            // "Apple" is redefined on the last statement, no port for first statement.
            Assert.IsFalse(CodeBlockUtils.DoesStatementRequireOutputPort(svs, 0));

            // None of the variables on statement 1 is redefined, so show output port.
            Assert.IsTrue(CodeBlockUtils.DoesStatementRequireOutputPort(svs, 1));

            // The last line will display an output port as long as it defines variable.
            Assert.IsTrue(CodeBlockUtils.DoesStatementRequireOutputPort(svs, 2));
        }
示例#2
0
        public void StatementRequiresOutputPort00()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                // Null as argument will cause exception.
                CodeBlockUtils.DoesStatementRequireOutputPort(null, 0);
            });

            // Create a list of another empty list.
            var svs = new List <List <string> >()
            {
                new List <string>()
            };

            Assert.Throws <IndexOutOfRangeException>(() =>
            {
                // -1 as index argument will cause exception.
                CodeBlockUtils.DoesStatementRequireOutputPort(svs, -1);
            });

            Assert.Throws <IndexOutOfRangeException>(() =>
            {
                // Out-of-bound index argument will cause exception.
                CodeBlockUtils.DoesStatementRequireOutputPort(svs, 1);
            });
        }
示例#3
0
        public void StatementRequiresOutputPort01()
        {
            var svs = new List <List <string> >(); // An empty list should return false.

            Assert.IsFalse(CodeBlockUtils.DoesStatementRequireOutputPort(svs, 0));
        }