public void FillWith(Case otherCase) { Debug.Assert(otherCase.ParameterName == ParameterName); CaseExpressions.AddRange(otherCase.CaseExpressions); CriteriaAnalysis.AddRange(otherCase.CriteriaAnalysis); if (otherCase.HasError) { HasError = true; } }
public void Add(ExpressionSyntax caseExpression, CriteriaAnalysis criterion, bool hasError) { if (caseExpression != null) { CaseExpressions.Add(caseExpression); } CriteriaAnalysis.Add(criterion); if (hasError) { HasError = true; } }
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 override int GetHashCode() => CriteriaAnalysis.Aggregate(ParameterName.GetHashCode(), (current, field) => current ^ field.GetHashCode());
private bool Equals(Case other) => string.Equals(ParameterName, other?.ParameterName) && // ReSharper disable once PossibleNullReferenceException CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
private bool Equals(Case other) => other != null && TestedParameter.Equals(other.TestedParameter) && // ReSharper disable once PossibleNullReferenceException CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
public CasesAndOr(ExpressionSyntax casesExpression, ExpressionSyntax parameterNameExpression, string parameterName, CriteriaAnalysis criteria, bool hasError) { CasesAnd.Add(new CasesAnd(parameterNameExpression, parameterName, casesExpression, criteria, hasError)); }
private CasesAndOr(string parameterName, CriteriaAnalysis criteria, bool hasError) { CasesAnd.Add(new CasesAnd(null, parameterName, null, criteria, hasError)); }
public CasesAnd(ExpressionSyntax parameterNameExpression, string parameterName, ExpressionSyntax caseExpression, CriteriaAnalysis criterion, bool hasError) { Debug.Assert(parameterName != null); if (!Cases.TryGetValue(parameterName, out Case currentCase)) { currentCase = new Case(parameterNameExpression, parameterName); Cases[parameterName] = 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; }