예제 #1
0
        public void TruthTable_CalculateTruthTable_HashCodeBeEqualAsExpected(string prefixInput, string hexaHashCode)
        {
            //Arrange
            var binaryTree = ParsingModule.Parse(prefixInput);

            //Act
            var truthTable = new TruthTable(binaryTree);

            //Assert
            Assert.Equal(truthTable.GetHexadecimalHashCode(), hexaHashCode);
        }
        public void InFixFormulaTesting_OnPredicateFormula_CorrectInfixFormula(string prefixInput, string infixOutput)
        {
            //Arrange
            var formulaGenerator = new InfixFormulaGenerator();
            var binaryTree       = ParsingModule.Parse(prefixInput);

            //Act
            formulaGenerator.Calculate(binaryTree.Root);

            //Assert
            Assert.Equal(infixOutput, binaryTree.Root.InFixFormula);
        }
예제 #3
0
        public void SemanticTableauxPredicate_OnNonTatologiesFormula_RootNotBeingClosed(string prefixInput)
        {
            //Arrange
            var binaryTreeNormal = ParsingModule.Parse($"~({prefixInput.Trim()})");
            var tableauxRoot     = new TableauxNode(binaryTreeNormal.Root as CompositeComponent);

            //Act
            tableauxRoot.IsClosed();

            //Assert
            Assert.Equal(false, tableauxRoot.LeafIsClosed);
        }
예제 #4
0
        public void Calculator_Disjunction_ReturnCorrectValue(string prefixInput, bool result)
        {
            //Arrange
            var calculator      = new Calculator();
            var binaryTree      = ParsingModule.Parse(prefixInput);
            var rootOfComponent = binaryTree.Root;

            //Act
            calculator.Calculate(rootOfComponent);

            //Assert
            Assert.Equal(rootOfComponent.Data, result);
        }
예제 #5
0
        public void TruthTable_SimplifyTruthTable_HashCodeBeEqualAsExpected(string prefixInput, string simplifiedTruthTable)
        {
            //Arrange
            var binaryTree = ParsingModule.Parse(prefixInput);

            //Act
            var truthTable = new TruthTable(binaryTree);

            //Assert
            var actualSimplified   = DeleteCharacters(truthTable.SimplifiedToString(), new[] { "\n", " ", });
            var expectedSimplified = DeleteCharacters(simplifiedTruthTable, new[] { "\n", " ", });

            Assert.Equal(actualSimplified, expectedSimplified);
        }
예제 #6
0
        public void TruthTable_Nandify_NandTruthTableHashCodeBeAsExpected(string prefixInput)
        {
            //Arrange
            var nandify    = new Nandify();
            var binaryTree = ParsingModule.Parse(prefixInput);

            //Act
            var truthTable = new TruthTable(binaryTree);

            nandify.Calculate(binaryTree.Root);
            var truthTableNand = new TruthTable(Nandify.BinaryTree);

            //Assert
            Assert.Equal(truthTable.GetHexadecimalHashCode(), truthTableNand.GetHexadecimalHashCode());
        }
예제 #7
0
        public void TruthTable_DNFProcessing_DNFFormulaAndHashCodeBeAsExpected(string prefixInput)
        {
            //Arrange
            var binaryTree = ParsingModule.Parse(prefixInput);

            //Act
            var truthTable = new TruthTable(binaryTree);

            truthTable.ProcessDnf();
            if (truthTable.DnfNormalComponents.Count == 0)
            {
                return;
            }
            var truthTableDnf = new TruthTable(truthTable.DnfNormalBinaryTree);

            //Assert
            Assert.Equal(truthTableDnf.GetHexadecimalHashCode(), truthTable.GetHexadecimalHashCode());
            Assert.Equal(truthTableDnf.GetHexadecimalSimplifiedHashCode(), truthTable.GetHexadecimalSimplifiedHashCode());
        }