Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public CasesAndOr(ExpressionSyntax casesExpression, TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(testedParameter, casesExpression, criteria, hasError));
 }
Ejemplo n.º 4
0
 private CasesAndOr(TestedParameter testedParameter, CriteriaAnalysis criteria, bool hasError)
 {
     CasesAnd.Add(new CasesAnd(testedParameter, null, criteria, hasError));
 }
Ejemplo n.º 5
0
 public Case(TestedParameter testedParameter)
 {
     Debug.Assert(testedParameter?.Name != null);
     TestedParameter = testedParameter;
 }
Ejemplo n.º 6
0
 public override int GetHashCode() => CriteriaAnalysis.Aggregate(TestedParameter.GetHashCode(), (current, field) => current ^ field.GetHashCode());
Ejemplo n.º 7
0
 private bool Equals(Case other) => other != null &&
 TestedParameter.Equals(other.TestedParameter) &&
 // ReSharper disable once PossibleNullReferenceException
 CriteriaAnalysis.Equivalent(other.CriteriaAnalysis);
Ejemplo n.º 8
0
 public bool Equals( TestedParameter other ) => string.Equals( Name, other.Name ) && string.Equals( Path, other.Path );