Beispiel #1
0
        public void GetSimplifiedExpression_ExpressionWithoutDoNotCareVariableGiven_ExpectedEqualNumberOfVariablesInProposition(string nonSimplifiableExpression)
        {
            // Arrange
            parser = new Parser(nonSimplifiableExpression);
            Proposition nonSimplifiableProposition = parser.Parse();

            TruthTable  truthTable           = new TruthTable(nonSimplifiableProposition);
            TruthTable  simplifiedTruthTable = truthTable.Simplify();
            Proposition afterSimplifying     = simplifiedTruthTable.GetSimplifiedExpression();

            // Act
            int numberOfVariablesInOriginal         = nonSimplifiableProposition.GetVariables().Count;
            int actualNumberOfVariablesInSimplified = afterSimplifying.GetVariables().Count;

            int actualNumberOfDontCareVariables = numberOfVariablesInOriginal - actualNumberOfVariablesInSimplified;

            // Assert
            actualNumberOfDontCareVariables.Should().Be(0, $"Because the proposition could NOT be simplified thus should have a difference of 0");
        }
Beispiel #2
0
        public void GetSimplifiedExpression_ExpressionWithDoNotCareVariableGiven_ExpectedDoNoCareVariableToBeRemovedFromProposition(string simplifiableExpression, int numberOfDoNotCareVariables)
        {
            // Arrange
            parser = new Parser(simplifiableExpression);
            Proposition simplifiableProposition = parser.Parse();

            TruthTable  truthTable           = new TruthTable(simplifiableProposition);
            TruthTable  simplifiedTruthTable = truthTable.Simplify();
            Proposition afterSimplifying     = simplifiedTruthTable.GetSimplifiedExpression();

            // Act
            int numberOfVariablesInOriginal         = simplifiableProposition.GetVariables().Count;
            int actualNumberOfVariablesInSimplified = afterSimplifying.GetVariables().Count;

            int actualNumberOfDontCareVariables = numberOfVariablesInOriginal - actualNumberOfVariablesInSimplified;

            // Assert
            actualNumberOfDontCareVariables.Should().Be(numberOfDoNotCareVariables, $"Because the proposition could be simplified and {numberOfDoNotCareVariables} variables should be removed from the original expression that has {numberOfVariablesInOriginal} variables");
        }