public static ExpressionStructureDto EvaluateExpression(string expressionValue) { ExpressionStructure structure = new ExpressionStructure(new PrefixExpression(expressionValue)); structure.BuildExpressionTree(); structure.BuildTruthTable(); return(new ExpressionStructureDto(structure)); }
public void BuildTruthTable_Should_Create_TruthTable_From_ExpressionTree() { ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object); structure.BuildExpressionTree(); structure.BuildTruthTable(); structure.TruthTable.Should().NotBeNull(); }
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); }
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(); }
public void BuildTruthTable_Should_Throw_NullReferenceException_When_The_ExpressionTree_Is_Null() { ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object); Assert.Throws <NullReferenceException>(() => structure.BuildTruthTable()); }
public void ToString_Should_Return_InfixNotation_From_PrefixExpression() { ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object); structure.ToString().Should().BeEquivalentTo(VALID_INFIX); }
public void Should_Create_ExpressionStructure_With_Passed_Valid_Prefix_Expression() { ExpressionStructure structure = new ExpressionStructure(_mockPrefixExpression.Object); structure.PrefixExpression.Value.Should().BeEquivalentTo(VALID_PREFIX); }