public CasesAnd(TestedParameter testedParameter, ExpressionSyntax caseExpression, CriteriaAnalysis criterion, bool hasError) { Debug.Assert(testedParameter?.Name != null); if (!Cases.TryGetValue(testedParameter, out Case currentCase)) { currentCase = new Case(testedParameter); Cases[testedParameter] = currentCase; } currentCase.Add(caseExpression, criterion, hasError); if (currentCase.HasError) { HasError = true; } if (caseExpression == null) { // other cases return; } var testMethod = caseExpression.FirstAncestorOrSelf <MethodDeclarationSyntax>(); var testClass = testMethod.FirstAncestorOrSelf <ClassDeclarationSyntax>(); var testNamespace = testClass.FirstAncestorOrSelf <NamespaceDeclarationSyntax>(); TestNamespaceName = testNamespace.GetFullName(); TestClassName = testClass.GetFullName(false); TestName = testMethod.Identifier.Text; var span = caseExpression.GetLocation().GetLineSpan(); TestFileName = span.Path; TestLine = span.StartLinePosition.Line + 1; }
private static CasesAndOr ComputeAllCases(TestedParameter testedParameter, Dictionary <TestedParameter, CriteriaValues> .ValueCollection criteriaValues) { var result = new CasesAndOr(); foreach (var criteriaValue in criteriaValues) { var cases = new CasesAndOr(); foreach (var criterion in criteriaValue.Values) { cases.CombineOr(new CasesAndOr(testedParameter, criterion.Analysis, criterion.IsError)); } result.CombineAnd(cases); } return(result); }
public CasesAndOr(ExpressionSyntax casesExpression, TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError) { CasesAnd.Add(new CasesAnd(testedParameter, casesExpression, criteria, hasError)); }
private CasesAndOr(TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError) { CasesAnd.Add(new CasesAnd(testedParameter, null, criteria, hasError)); }
public Case(TestedParameter testedParameter) { Debug.Assert(testedParameter?.Name != null); TestedParameter = testedParameter; }
public override int GetHashCode() => CriteriaAnalysis.Aggregate(TestedParameter.GetHashCode(), (current, field) => current ^ field.GetHashCode());
private bool Equals(Case other) => other != null && TestedParameter.Equals(other.TestedParameter) && // ReSharper disable once PossibleNullReferenceException CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
public bool Equals( TestedParameter other ) => string.Equals( Name, other.Name ) && string.Equals( Path, other.Path );