Inheritance: CommandBase
Ejemplo n.º 1
0
        public void TestColumns()
        {
            Expect.Once.On(m_ResultViewHelper).Method("AddColumn").With("Determinate", "!Test");

            for (int i = 0; i < 10; i++)
            {
                Expect.Once.On(m_ResultViewHelper).Method("AddItem");
            }

            IRandom random = m_Mockery.NewMock<IRandom>();
            Project project = new Project(random);

            Rule rule = new Rule();

            Expect.AtLeastOnce.On(random).Method("NextDouble").Will(Return.Value((double)0.5));

            rule.Name = "test";
            rule.Probability = 1.0;
            rule.LineNumber = 1;

            LiteralCommand a = new LiteralCommand();
            a.Literal = "a";
            rule.Commands.Add(a);

            Rule rule2 = new Rule();

            rule2.Name = "test2";
            rule2.Probability = 1.0;
            rule2.LineNumber = 1;

            LiteralCommand b = new LiteralCommand();
            b.Literal = "b";
            rule2.Commands.Add(b);

            project.Rules.Add(rule);
            project.Rules.Add(rule2);

            MarkCommand m = new MarkCommand();
            m.Name = "Test";
            m.Value = "yes";

            rule2.Commands.Add(m);

            project.StartRules.Add("test", 5);
            project.StartRules.Add("test2", 5);

            project.Columns.Add("Determinate", "!Test");

            m_GeneratorController.Generate(project);

            Assert.AreEqual(2, project.StartRules.Count);
            m_Mockery.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 2
0
        public void TestGenerateOneStartingRule()
        {
            for (int i = 0; i < 10; i++)
            {
                Expect.Once.On(m_ResultViewHelper).Method("AddItem");
            }

            IRandom random = m_Mockery.NewMock<IRandom>();
            Project project = new Project(random);

            Rule rule = new Rule();

            rule.Name = "test";
            rule.Probability = 1.0;
            rule.LineNumber = 1;

            LiteralCommand a = new LiteralCommand();
            a.Literal = "a";
            rule.Commands.Add(a);

            project.Rules.Add(rule);

            project.StartRules.Add("test", 10);

            Expect.AtLeastOnce.On(random).Method("NextDouble").Will(Return.Value((double)0.5));

            m_GeneratorController.Generate(project);

            Assert.AreEqual(1, project.StartRules.Count);
            m_Mockery.VerifyAllExpectationsHaveBeenMet();
        }