private ObjectTheoremResult TryToRemoveWrongAssumption(EFRoslynTheorem efRoslynTheorem, ObjectTheoremResult result, List <IClassAssumption> classAssumptions, List <IPropertyAssumption> propertyAssumptions) { foreach (var assumes in classAssumptions) { if (result.IsAssumptionWrong(assumes.Assumption)) { classAssumptions.Remove(assumes); efRoslynTheorem.RemoveAssumption(assumes.Assumption); return(efRoslynTheorem.ReSolve()); } } foreach (var assumes in propertyAssumptions) { if (result.IsAssumptionWrong(assumes.Assumption)) { propertyAssumptions.Remove(assumes); efRoslynTheorem.RemoveAssumption(assumes.Assumption); return(efRoslynTheorem.ReSolve()); } } return(null); }
public async Task RoslynWith_EFScenarioBad() { // Arrange var projectFilePath = @"..\..\..\EFScenario.Bad\EFScenario.Bad.csproj"; var compilation = await LoadProjectAndGetCompilationAsync(projectFilePath); INamedTypeSymbol dbContextTypeSymbol; var entityTypeSymbols = SymbolHelper.GetAllEntityTypesFromDbContext(compilation, out dbContextTypeSymbol); // Act var efRoslynTheorem = new EFRoslynTheorem(); ObjectTheoremResult solved = efRoslynTheorem.Solve(entityTypeSymbols); // Assert Assert.IsNotNull(solved); Assert.AreEqual(Status.Unsatisfiable, solved.Status); foreach (var assumes in efRoslynTheorem.ClassAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } foreach (var assumes in efRoslynTheorem.PropertyAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } solved = efRoslynTheorem.ReSolve(); Assert.IsNotNull(solved); Assert.AreEqual(Status.Satisfiable, solved.Status); }
public async Task RoslynWith_EFScenarioBad() { // Arrange var projectFilePath = @"..\..\..\EFScenario.Bad\EFScenario.Bad.csproj"; var compilation = await LoadProjectAndGetCompilationAsync(projectFilePath); INamedTypeSymbol dbContextTypeSymbol; var entityTypeSymbols = SymbolHelper.GetAllEntityTypesFromDbContext(compilation, out dbContextTypeSymbol); // Act var efRoslynTheorem = new EFRoslynTheorem(); ObjectTheoremResult solved = efRoslynTheorem.Solve(entityTypeSymbols); // Assert Assert.IsNotNull(solved); Assert.AreEqual(Status.Unsatisfiable, solved.Status); foreach (var assumes in efRoslynTheorem.ClassAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } foreach (var assumes in efRoslynTheorem.PropertyAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } solved = efRoslynTheorem.ReSolve(); Assert.IsNotNull(solved); Assert.AreEqual(Status.Satisfiable, solved.Status); }
public async Task TestMethod1() { // Arrange var projectFilePath = @"..\..\..\Z3.ObjectTheorem.EF.RoslynIntegration.PerfTests\Z3.ObjectTheorem.EF.RoslynIntegration.PerfTests.csproj"; var compilation = await LoadProjectAndGetCompilationAsync(projectFilePath); var scenarioClasses = compilation.GetSymbolsWithName(s => s.StartsWith("ScenarioClass"), SymbolFilter.Type).Cast <INamedTypeSymbol>(); var allMemberSymbols = scenarioClasses.SelectMany(t => t.GetMembers().Where(m => m.Kind == SymbolKind.Property)); Trace.WriteLine("Class count: " + scenarioClasses.Count()); Trace.WriteLine("Total Property count: " + allMemberSymbols.Count()); Trace.WriteLine("Property per class count: " + allMemberSymbols.Count() / scenarioClasses.Count()); Trace.WriteLine(""); // Act var efRoslynTheorem = new EFRoslynTheorem(); ObjectTheoremResult solved = efRoslynTheorem.Solve(scenarioClasses); // Assert Assert.IsNotNull(solved); Assert.AreEqual(Status.Unsatisfiable, solved.Status); foreach (var assumes in efRoslynTheorem.ClassAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } foreach (var assumes in efRoslynTheorem.PropertyAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } Trace.WriteLine(""); solved = efRoslynTheorem.ReSolve(); Assert.IsNotNull(solved); Assert.AreEqual(Status.Satisfiable, solved.Status); }
public async Task TestMethod1() { // Arrange var projectFilePath = @"..\..\..\Z3.ObjectTheorem.EF.RoslynIntegration.PerfTests\Z3.ObjectTheorem.EF.RoslynIntegration.PerfTests.csproj"; var compilation = await LoadProjectAndGetCompilationAsync(projectFilePath); var scenarioClasses = compilation.GetSymbolsWithName(s => s.StartsWith("ScenarioClass"), SymbolFilter.Type).Cast<INamedTypeSymbol>(); var allMemberSymbols = scenarioClasses.SelectMany(t => t.GetMembers().Where(m => m.Kind == SymbolKind.Property)); Trace.WriteLine("Class count: " + scenarioClasses.Count()); Trace.WriteLine("Total Property count: " + allMemberSymbols.Count()); Trace.WriteLine("Property per class count: " + allMemberSymbols.Count() / scenarioClasses.Count()); Trace.WriteLine(""); // Act var efRoslynTheorem = new EFRoslynTheorem(); ObjectTheoremResult solved = efRoslynTheorem.Solve(scenarioClasses); // Assert Assert.IsNotNull(solved); Assert.AreEqual(Status.Unsatisfiable, solved.Status); foreach (var assumes in efRoslynTheorem.ClassAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } foreach (var assumes in efRoslynTheorem.PropertyAssumptions) { efRoslynTheorem.RemoveAssumption(assumes.Assumption); } Trace.WriteLine(""); solved = efRoslynTheorem.ReSolve(); Assert.IsNotNull(solved); Assert.AreEqual(Status.Satisfiable, solved.Status); }