public void InvalidSection()
        {
            string input = @"$variables: 2;
                             $unknown: a = 10;
                             $function: x[0] + a;";

            TestUtils.ExpectThrow(() => SectionsParser.Split(input));
        }
        public void ConstraintsSectionOnly()
        {
            string input = "$constraints:\nx[0] <= 100;\nx[1] >= 200;\n";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(1, sections.Count);
            Assert.IsInstanceOfType(sections[0], typeof(ConstraintsSection));
            Assert.AreEqual("x[0] <= 100;\nx[1] >= 200;", sections[0].Content.Trim());
        }
        public void CostFunctionSectionOnly()
        {
            string input = "$function:\na * x[0] + b;";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(1, sections.Count);
            Assert.IsInstanceOfType(sections[0], typeof(CostFunctionSection));
            Assert.AreEqual("a * x[0] + b;", sections[0].Content.Trim());
        }
        public void ParametersSectionOnly()
        {
            string input = "$parameters:\na = 10; b = 20;\n";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(1, sections.Count);
            Assert.IsInstanceOfType(sections[0], typeof(ParametersSection));
            Assert.AreEqual("a = 10; b = 20;", sections[0].Content.Trim());
        }
        public void RankSectionOnly()
        {
            string input = "$variables: 3;";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(1, sections.Count);
            Assert.IsInstanceOfType(sections[0], typeof(DimensionSection));
            Assert.AreEqual("3;", sections[0].Content.Trim());
        }
        public void NonUniqueSections()
        {
            string input = @"$variables: 2;
                             $parameters: a = 10;
                             $variables: 3;";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(3, sections.Count);
            TestUtils.ExpectThrow(() => SectionsParser.EnforceSectionsAreUnique(sections));
        }
        public void MultipleSections()
        {
            string input = @"$variables: 2;
                             $parameters: a = 10;
                             $function: x[0] + a;";

            var sections = SectionsParser.Split(input);

            Assert.AreEqual(3, sections.Count);
            Assert.IsInstanceOfType(sections[0], typeof(DimensionSection));
            Assert.IsInstanceOfType(sections[1], typeof(ParametersSection));
            Assert.IsInstanceOfType(sections[2], typeof(CostFunctionSection));
        }