public void GenerateExpression_RandomExpressionGeneratedAndPassedToLogicAppForParsing_ExpectedAllHashCodesToMatch()
        {
            // Arrange
            // re-use logic app for not repeating large procedure and for all the hash codes.
            LogicApp             logicApp             = new LogicApp(new Parser());
            PropositionGenerator propositionGenerator = new PropositionGenerator();

            // Act
            Proposition randomExpression = propositionGenerator.GenerateExpression();

            logicApp.Parse(randomExpression);

            bool hashCodesMatched = logicApp.HashCodesMatched();

            // Assert
            hashCodesMatched.Should().BeTrue("Because a valid expression should be generated");
        }
Example #2
0
        public void Parse_ValidPropositionsWithLiterals_LogicAppShouldHaveAssignedAllRelatedProperties(string propositionExpression, int expectedNumberOfVariables)
        {
            // Arrange // Act
            logicApp.Parse(propositionExpression);
            int actualNumberOfVariables = logicApp.Variables.Count;

            // Assert
            actualNumberOfVariables.Should().Be(expectedNumberOfVariables, "Because the every unique variable should be added to the list");

            string propositionRelatedMessage = "Because the proposition should be successfully parsed an assigned";

            logicApp.Root.Should().NotBeNull(propositionRelatedMessage);
            logicApp.DisjunctiveNormalForm.Should().NotBeNull(propositionRelatedMessage);
            logicApp.Nandified.Should().NotBeNull(propositionRelatedMessage);

            string truthTableRelatedMessage = "Because the truthtables should be successfully created and assigned after parsing";

            logicApp.TruthTable.Should().NotBeNull(truthTableRelatedMessage);
            logicApp.SimplifiedTruthTable.Should().NotBeNull(truthTableRelatedMessage);

            logicApp.HashCodes.Count.Should().Be(LogicApp.hashCodeLabels.Count, "Because for each proposition a hash code should be generated");
        }