コード例 #1
0
        protected override void Check()
        {
            var c = new C {
                F = 3, G = 7, X = 3
            };
            var     m  = InitializeModel(c);
            Formula s1 = c.F == 3;
            Formula s2 = c.G == 7;
            Formula s3 = c.F == c.X;

            var f0 = s1 || s2;
            var f1 = s1 && s2;
            var f2 = s1.Implies(s3);
            var f3 = s1.EquivalentTo(s3);
            var f4 = f3.Implies(f2);
            var f5 = f2.EquivalentTo(s2);

            Create(m, f0, f1, f2, f3, f4, f5);
            RootComponents.Length.ShouldBe(1);

            Formulas.Length.ShouldBe(6);
            ExecutableStateFormulas.Length.ShouldBe(3);

            var root = RootComponents[0];

            root.ShouldBeOfType <C>();
            c = (C)root;

            RuntimeModel.Evaluate(Formulas[0]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[1]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[2]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[3]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[4]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[5]).ShouldBe(true);

            c.X = 9;
            RuntimeModel.Evaluate(Formulas[2]).ShouldBe(false);
            RuntimeModel.Evaluate(Formulas[3]).ShouldBe(false);
            RuntimeModel.Evaluate(Formulas[4]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[5]).ShouldBe(false);

            c.X = 3;
            c.G = 8;

            RuntimeModel.Evaluate(Formulas[0]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[1]).ShouldBe(false);

            c.F = 9;

            RuntimeModel.Evaluate(Formulas[0]).ShouldBe(false);
            RuntimeModel.Evaluate(Formulas[1]).ShouldBe(false);
            RuntimeModel.Evaluate(Formulas[2]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[3]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[4]).ShouldBe(true);
            RuntimeModel.Evaluate(Formulas[5]).ShouldBe(false);
        }