예제 #1
0
 public void FillWith(Case otherCase)
 {
     Debug.Assert(otherCase.ParameterName == ParameterName);
     CaseExpressions.AddRange(otherCase.CaseExpressions);
     CriteriaAnalysis.AddRange(otherCase.CriteriaAnalysis);
     if (otherCase.HasError)
     {
         HasError = true;
     }
 }
예제 #2
0
        public void Add(ExpressionSyntax caseExpression, CriteriaAnalysis criterion, bool hasError)
        {
            if (caseExpression != null)
            {
                CaseExpressions.Add(caseExpression);
            }

            CriteriaAnalysis.Add(criterion);
            if (hasError)
            {
                HasError = true;
            }
        }
예제 #3
0
 public CasesAndOr(ExpressionSyntax casesExpression, TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(testedParameter, casesExpression, criteria, hasError));
 }
예제 #4
0
 private CasesAndOr(TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(testedParameter, null, criteria, hasError));
 }
예제 #5
0
 public override int GetHashCode() => CriteriaAnalysis.Aggregate(ParameterName.GetHashCode(), (current, field) => current ^ field.GetHashCode());
예제 #6
0
 private bool Equals(Case other) => string.Equals(ParameterName, other?.ParameterName) &&
 // ReSharper disable once PossibleNullReferenceException
 CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
예제 #7
0
 private bool Equals(Case other) => other != null &&
 TestedParameter.Equals(other.TestedParameter) &&
 // ReSharper disable once PossibleNullReferenceException
 CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
예제 #8
0
 public CasesAndOr(ExpressionSyntax casesExpression, ExpressionSyntax parameterNameExpression, string parameterName, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(parameterNameExpression, parameterName, casesExpression, criteria, hasError));
 }
예제 #9
0
 private CasesAndOr(string parameterName, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(null, parameterName, null, criteria, hasError));
 }
예제 #10
0
        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;
        }