Exemplo n.º 1
0
        public static ExpressionStructureDto EvaluateExpression(string expressionValue)
        {
            ExpressionStructure structure = new ExpressionStructure(new PrefixExpression(expressionValue));

            structure.BuildExpressionTree();
            structure.BuildTruthTable();
            return(new ExpressionStructureDto(structure));
        }
Exemplo n.º 2
0
        public void BuildTruthTable_Should_Create_TruthTable_From_ExpressionTree()
        {
            ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object);

            structure.BuildExpressionTree();
            structure.BuildTruthTable();

            structure.TruthTable.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public void BuildExpressionTree_Should_Invoke_BuildingOfExpressionTree_On_Prefix_Expression(string prefixExpressionValue)
        {
            var mockTree = new Mock <IBinaryExpressionTree>();

            _mockPrefixExpression.Setup(p => p.BuildExpressionTree()).Returns(mockTree.Object);
            ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object);

            structure.BuildExpressionTree();

            _mockPrefixExpression.Verify(p => p.BuildExpressionTree());
            structure.ExpressionTree.Should().BeEquivalentTo(mockTree.Object);
        }
Exemplo n.º 4
0
 public ExpressionStructureDto(ExpressionStructure structure)
 {
     this.TruthTable           = structure.TruthTable.Value;
     this.SimplifiedTruthTable = new SimplifiedTruthTableValues
     {
         Values            = structure.TruthTable.Simplify(),
         DontCareCharacter = QuineMcCluskey.DONT_CARE
     };
     this.HexResult     = structure.TruthTable.HexResult;
     this.Nodes         = structure.ExpressionTree.GetNodes();
     this.Edges         = structure.ExpressionTree.GetEdges();
     this.Leafs         = System.String.Join(",", structure.ExpressionTree.GetLeafs());
     this.DNF           = structure.TruthTable.NormalizeOriginal().Value;
     this.SimplifiedDNF = structure.TruthTable.NormalizeSimplified().Value;
     this.InfixNotation = structure.ToString();
     this.Nandify       = structure.PrefixExpression.NandifyExpression();
 }
Exemplo n.º 5
0
        public void BuildTruthTable_Should_Throw_NullReferenceException_When_The_ExpressionTree_Is_Null()
        {
            ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object);

            Assert.Throws <NullReferenceException>(() => structure.BuildTruthTable());
        }
Exemplo n.º 6
0
        public void ToString_Should_Return_InfixNotation_From_PrefixExpression()
        {
            ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object);

            structure.ToString().Should().BeEquivalentTo(VALID_INFIX);
        }
Exemplo n.º 7
0
        public void Should_Create_ExpressionStructure_With_Passed_Valid_Prefix_Expression()
        {
            ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object);

            structure.PrefixExpression.Value.Should().BeEquivalentTo(VALID_PREFIX);
        }