Exemple #1
0
        public ExceptionExpectancyCodeAction(Document document, MethodDeclarationSyntax method,
                                             SemanticModel semanticModel, NUnitFramework.Symbols nunit)
        {
            _document            = document;
            _method              = method;
            _model               = new ExceptionExpectancyMethodModel(method, semanticModel, nunit);
            _clusters            = TestCaseExceptionEquivalenceCluster.CreateMany(_model);
            _methodLineSeparator = GetMethodLineSeparator(method);

            Debug.Assert(_clusters.Length > 0, "_clusters.Length > 0");
        }
Exemple #2
0
        private MethodDeclarationSyntax ProduceTestMethodForExceptionCluster(
            TestCaseExceptionEquivalenceCluster cluster, int clustersCount, TestMethodNamer testMethodNamer)
        {
            var testCasesToRemain   = cluster.EquivalentItems.Select(i => i.AttributeNode).ToArray();
            var exceptionExpectancy = cluster.EquivalentItems.First();

            var clusterMethod = _method.WithoutExceptionExpectancyInAttributes(testCasesToRemain)
                                .WithBody(CreateAssertedBlock(exceptionExpectancy)).WithTrailingTrivia(CreateClusterMethodTrailingTrivia(cluster))
                                .WithIdentifier(testMethodNamer.CreateName(exceptionExpectancy, clustersCount));

            return(clusterMethod);
        }
Exemple #3
0
 private SyntaxTriviaList CreateClusterMethodTrailingTrivia(TestCaseExceptionEquivalenceCluster cluster)
 {
     return(cluster == _clusters.Last()
         ? _method.GetTrailingTrivia()
         : _methodLineSeparator);
 }