Exemplo n.º 1
0
        public void GetTruthValueDictTest()
        {
            Variable p = new Variable('p');
            Variable q = new Variable('q');
            And      a = new And(p, q);

            Dictionary <char, bool> dict = new Dictionary <char, bool>();

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    dict['p'] = i == 1;
                    dict['q'] = j == 1;

                    Assert.AreEqual((i & j) == 1, a.GetTruthValue(dict));
                }
            }

            dict.Remove('p');
            Assert.ThrowsException <KeyNotFoundException>(
                () => a.GetTruthValue(dict));
        }
Exemplo n.º 2
0
        public void GetTruthValueArrayTest()
        {
            Variable p = new Variable('p');
            Variable q = new Variable('q');
            And      a = new And(p, q);

            bool[] dict = new bool[130];

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    dict['p'] = i == 1;
                    dict['q'] = j == 1;

                    Assert.AreEqual((i & j) == 1, a.GetTruthValue(dict));
                }
            }
        }