Ejemplo n.º 1
0
 private char[] CalculateTruthTableChar()
 {
     char[] truthColumn = new char[CombinationsCount];
     for (int k = 0; k < CombinationsCount; k++)
     {
         truthColumn[k] = (Proposition.Calculate(GetRow(k)) == true) ? '1' : '0';
     }
     return(truthColumn);
 }
Ejemplo n.º 2
0
 private bool[] CalculateTruthTable()
 {
     bool[] truthColumn = new bool[CombinationsCount];
     for (int k = 0; k < CombinationsCount; k++)
     {
         truthColumn[k] = Proposition.Calculate(GetRow(k));
     }
     return(truthColumn);
 }
Ejemplo n.º 3
0
        public void Calculate_CallToCalculateWithDifferentTruthValues_ShouldAlwaysReturnFalse(bool truthValue)
        {
            // Arrange
            constant.TruthValue = truthValue;

            // Act
            bool actualTruthValue = constant.Calculate();

            // Assert
            ActualTruthValueShouldBe(actualTruthValue);
        }
Ejemplo n.º 4
0
        public void Calculate_NoTruthValueAssigned_ExpectedFalseReturned()
        {
            // Arrange
            Proposition proposition = new Proposition('A');

            // Act
            bool actualResult = proposition.Calculate();

            // Assert
            actualResult.Should().BeFalse("because TruthValue was never assigned and defaults to false");
        }
Ejemplo n.º 5
0
        public void Calculate_AssignTruthValueToProposition_ExpectedAssignedTruthValueReturned(bool truthValue)
        {
            // Arrange
            VALID_PROPOSITION.TruthValue = truthValue;

            // Act
            bool actualResult = VALID_PROPOSITION.Calculate();

            // Assert
            actualResult.Should().Be(truthValue, "because the assigned truthValue should be returned");
        }
Ejemplo n.º 6
0
        public void CreateContradictionFromProposition_ValidPropositionGiven_ExpectedAllAssignmentsToResultInFalse(bool truthValue)
        {
            // Arrange
            Proposition randomProposition = PropositionGenerator.GetRandomProposition();
            Proposition contradiction     = PropositionGenerator.CreateContradictionFromProposition(randomProposition);

            contradiction.TruthValue = truthValue;

            // Act
            bool actualTruthValue = contradiction.Calculate();

            // Assert
            actualTruthValue.Should().BeFalse("Because a contradiction should always evaluate to false");
        }
Ejemplo n.º 7
0
        public void CreateTautologyFromProposition_ValidPropositionGiven_ExpectedAllAssignmentsToResultInTrue(bool truthValue)
        {
            // Arrange
            Proposition randomProposition = PropositionGenerator.GetRandomProposition();
            Proposition tautology         = PropositionGenerator.CreateTautologyFromProposition(randomProposition);

            tautology.TruthValue = truthValue;

            // Act
            bool actualTruthValue = tautology.Calculate();

            // Assert
            actualTruthValue.Should().BeTrue("Because a tautology should always evaluate to true");
        }