コード例 #1
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);
        }
コード例 #2
0
        private MethodDeclarationSyntax ProduceTestMethodForTestCaseWithExpectedExceptionEquivalence(
            ExpectedExceptionTestCaseEquivalence equivalence, int equivalenceCount, TestMethodNamer testMethodNamer)
        {
            var testCasesToRemain   = equivalence.EquivalentItems.Select(i => i.AttributeNode).ToArray();
            var exceptionExpectancy = equivalence.EquivalentItems.First();

            var clusterMethod = methodToBeFixed.WithoutExceptionExpectancyInAttributes(testCasesToRemain)
                                .WithBody(CreateAssertedBlock(exceptionExpectancy)).WithTrailingTrivia(CreateClusterMethodTrailingTrivia(equivalence))
                                .WithIdentifier(testMethodNamer.CreateName(exceptionExpectancy, equivalenceCount));

            return(clusterMethod);
        }
コード例 #3
0
        private IEnumerable <MethodDeclarationSyntax> ProduceFixedTestMethods()
        {
            var fixedMethods    = new List <MethodDeclarationSyntax>();
            var testMethodNamer = new TestMethodNamer(methodToBeFixed, migrator.ExceptionFreeTestCaseAttributeNodes.Any());

            if (TryProduceExceptionUnrelatedTestMethod(out MethodDeclarationSyntax fixedExceptionUnrelatedMethod))
            {
                fixedMethods.Add(fixedExceptionUnrelatedMethod);
            }
            foreach (var equivalence in equivalences)
            {
                fixedMethods.Add(ProduceTestMethodForTestCaseWithExpectedExceptionEquivalence(equivalence, equivalences.Length, testMethodNamer));
            }

            return(fixedMethods);
        }
コード例 #4
0
        private IEnumerable <MethodDeclarationSyntax> ProduceFixedTestMethods()
        {
            var fixedMethods    = new List <MethodDeclarationSyntax>();
            var testMethodNamer = new TestMethodNamer(_method, _model.ExceptionFreeTestCaseAttributeNodes.Any());

            if (TryProduceExceptionUnrelatedTestMethod(out MethodDeclarationSyntax fixedExceptionUnrelatedMethod))
            {
                fixedMethods.Add(fixedExceptionUnrelatedMethod);
            }

            foreach (var cluster in _clusters)
            {
                fixedMethods.Add(ProduceTestMethodForExceptionCluster(cluster, _clusters.Length, testMethodNamer));
            }

            return(fixedMethods);
        }