public async Task DetectsThreeDatabaseEntityDeclarations_When_EF60_NWProjectIsUsed() { //Arrange Solution EF60_NWSolution = await new RoslynSolutionGenerator().GetSolutionAsync(@"..\..\..\..\ProjectsUnderTest\EF60_NW\EF60_NW.sln"); var progressIndicator = new ProgressStub(); Context <EntityFramework> context = new ContextStub <EntityFramework>(); var dataContextDecExtr = new DataContextDeclarationExtractor(context); await dataContextDecExtr.FindDataContextDeclarationsAsync(EF60_NWSolution, progressIndicator); var target = new DatabaseEntityDeclarationExtractorUsingDbContextProperties(context); //Act await target.FindDatabaseEntityDeclarationsAsync(EF60_NWSolution, progressIndicator); //Assert Assert.IsTrue(target.DatabaseEntityDeclarations.Count == 3); IEnumerable <string> dbEntityNames = target.DatabaseEntityDeclarations.Select(d => d.Name); Assert.IsTrue(dbEntityNames.Contains("Customer")); Assert.IsTrue(dbEntityNames.Contains("Order")); Assert.IsTrue(dbEntityNames.Contains("OrderItem")); Assert.IsTrue(context.DatabaseEntityDeclarations == target.DatabaseEntityDeclarations); }
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); }