Exemple #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"));
        }
        public IExtractionManager GetExtractionManager()
        {
            var context                  = new ConcreteContext <EntityFramework>();
            var dataContextDecExt        = new DataContextDeclarationExtractor(context);
            var dbEntityExt              = new DatabaseEntityDeclarationExtractorUsingDbContextProperties(context);
            var dbAccessingMethodCallExt = new DatabaseAccessingMethodCallExtractor(context);
            var codeExecutionPathExt     = new CodeExecutionPathGenerator(context);
            var progressIndicator        = new Progress <ExtractionProgress>((e) => ProgressChanged(e));
            var serializer               = new NewtonsoftSerializer <EntityFramework>();

            IExtractionManager extractionManager = new ExtractionManager <EntityFramework>(dataContextDecExt, dbEntityExt, dbAccessingMethodCallExt, codeExecutionPathExt, progressIndicator, serializer);

            return(extractionManager);
        }
Exemple #4
0
 public ExtractionManager(DataContextDeclarationExtractor <T> dataContextDeclarationExtractor
                          , DatabaseEntityDeclarationExtractor <T> databaseEntityDeclarationExtractor
                          , DatabaseAccessingMethodCallExtractor <T> databaseAccessingMethodCallExtractor
                          , CodeExecutionPathGenerator <T> codeExecutionPathExtractor
                          , IProgress <ExtractionProgress> progressIndicator
                          , ISerializer <T> serializer)
 {
     _dataContextDeclarationExtractor      = dataContextDeclarationExtractor;
     _databaseEntityDeclarationExtractor   = databaseEntityDeclarationExtractor;
     _databaseAccessingMethodCallExtractor = databaseAccessingMethodCallExtractor;
     _codeExecutionPathExtractor           = codeExecutionPathExtractor;
     _progressIndicator = progressIndicator;
     _serializer        = serializer;
 }
        public RoslynSolutionBuilder WithTwoDocumentsContainingOneCodeExecutionPath()
        {
            DocumentId mainClassDocumentId       = DocumentId.CreateNewId(_projectId);
            DocumentId repositoryClassDocumentId = DocumentId.CreateNewId(_projectId);

            _roslynSolution.AddDocument(mainClassDocumentId, "Main.cs", string.Empty)
            .AddDocument(repositoryClassDocumentId, "Repository.cs", string.Empty);
            DatabaseAccessingMethodCallExtractor <FakeORMToolType> fakeDbAccessingMethodCallExt = GetDDAccessingMethodCallExtractorReturningOneMethodCall();

            var mockExtractorsFactory = new Mock <ExtractorFactory <FakeORMToolType> >();

            mockExtractorsFactory.Setup(m => m.GetDatabaseAccessingMethodCallsExtractor()).Returns(fakeDbAccessingMethodCallExt);

            return(this);
        }