Esempio n. 1
0
        public async Task ExtractsMethodCallsBetweenServiceAndRepositoryClasses_When_EF60_NWProjectIsUsed()
        {
            //Arrange
            Solution solution = await new RoslynSolutionGenerator().GetSolutionAsync(@"..\..\..\..\ProjectsUnderTest\EF60_NW\EF60_NW.sln");

            var progressIndicator = new ProgressStub();

            var context            = new ContextStub <EntityFramework>();
            var dataContextDecExtr = new DataContextDeclarationExtractor(context);
            await dataContextDecExtr.FindDataContextDeclarationsAsync(solution, progressIndicator);

            var dbEntityExtractor = new DatabaseEntityDeclarationExtractorUsingDbContextProperties(context);
            await dbEntityExtractor.FindDatabaseEntityDeclarationsAsync(solution, progressIndicator);

            var dbAccessingMethodCallsExtractor = new DatabaseAccessingMethodCallExtractor(context);
            await dbAccessingMethodCallsExtractor.FindDatabaseAccessingMethodCallsAsync(solution, progressIndicator);

            var target = new CodeExecutionPathGenerator(context);

            //Act
            await target.GenerateCodeExecutionPathsAsync(solution, progressIndicator);

            //Assert
            Assert.IsTrue(target.CodeExecutionPaths.Count() == 2);
        }
        public async Task ExtractsDatabaseAccessingMethodCallsWithRightParentMethodNames_When_EF60_NWProjectIsUsed()
        {
            //Arrange
            Solution solution = await new RoslynSolutionGenerator().GetSolutionAsync(@"..\..\..\..\ProjectsUnderTest\EF60_NW\EF60_NW.sln");

            var progressIndicator = new ProgressStub();

            var context            = new ContextStub <EntityFramework>();
            var dataContextDecExtr = new DataContextDeclarationExtractor(context);
            await dataContextDecExtr.FindDataContextDeclarationsAsync(solution, progressIndicator);

            var dbEntityExtractor = new DatabaseEntityDeclarationExtractorUsingDbContextProperties(context);
            await dbEntityExtractor.FindDatabaseEntityDeclarationsAsync(solution, progressIndicator);

            var target = new DatabaseAccessingMethodCallExtractor(context);

            //Act
            await target.FindDatabaseAccessingMethodCallsAsync(solution, progressIndicator);

            var result            = target.DatabaseAccessingMethodCalls;
            var parentMethodNames = result.Select(d => d.ParentMethodName);

            //Assert
            Assert.IsTrue(parentMethodNames.Contains("GetCustomerUsingQuerySyntaxAndAssignToVariable"));
            Assert.IsTrue(parentMethodNames.Contains("GetCustomerUsingQuerySyntax"));
            Assert.IsTrue(parentMethodNames.Contains("GetCustomerUsingMethodSyntax"));
            Assert.IsTrue(parentMethodNames.Contains("GetCustomerUsingMethodSyntaxAndAssignToVariable"));
            Assert.IsTrue(parentMethodNames.Contains("GetCustomerUsingMethodSyntaxAndQueryIsChangedInMultipleLines"));
            Assert.IsTrue(parentMethodNames.Contains("DoSomething"));
        }
Esempio n. 3
0
        private async Task ExtractDatabaseAccessingMethodCalls(string solutionUnderTest, Solution solution)
        {
            await _databaseAccessingMethodCallExtractor.FindDatabaseAccessingMethodCallsAsync(solution, _progressIndicator);

            _progressIndicator.Report(new ExtractionProgress("Saving Database Accessing Method Calls into json file."));
            await _serializer.Serialize(_databaseAccessingMethodCallExtractor.DatabaseAccessingMethodCalls, solutionUnderTest);

            _progressIndicator.Report(new ExtractionProgress("Done"));
        }