public void Test0() { var cci = new CciModuleSource(TestProjects.DsaPath); var cci2 = new CciModuleSource(TestProjects.DsaPath); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Deque") as NamedTypeDefinition; var method = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List <TypeIdentifier>(), new MethodIdentifier(method).InList()), SelectedOperators = new AOR_ArithmeticOperatorReplacement().InList <IMutationOperator>(), }; var exec = new MutationExecutor(null, choices, null); var container = new MutantsContainer(exec, new OriginalCodebase(cci.InList(), new List <string>()), new OptionsModel()); IList <AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mut = assemblies.Cast <CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection <CheckedNode>()) .OfType <Mutant>().First(); var sourceMethod = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); MutationResult executeMutation = exec.ExecuteMutation(mut, cci2).Result; // var viss = new Viss(cci2.Host, sourceMethod); // IModule newMod = viss.Rewrite(executeMutation.MutatedModules.Modules.Single().Module); cci2.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); MutationResult executeMutation2 = exec.ExecuteMutation(mut, cci2).Result; }
public void IntegrationTestingMiscUtilLight() { string filePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"..\..\..\..\Tests\SampleTestProjectsForTestDiscoveryAndExecution\SampleLogicNunit3Tests\bin\SampleLogic.dll")); string filePathTests = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"..\..\..\..\Tests\SampleTestProjectsForTestDiscoveryAndExecution\SampleLogicNunit3Tests\bin\SampleLogicNunit3Tests.dll")); var cci = new CciModuleSource(filePath); var choices = new MutationSessionChoices(); var tt = cci.Module.Module.GetAllTypes(); // var type = (NamedTypeDefinition)cci.Module.Module.GetAllTypes().Single(t => t.Name.Value == "Range"); // var method = new MethodIdentifier(type.Methods.First(m => m.Name.Value == "Contains")); MethodIdentifier method = null; choices.SelectedOperators.Add(new IdentityOperator2()); choices.Filter = method == null?MutationFilter.AllowAll() : new MutationFilter( new List <TypeIdentifier>(), method.InList()); var options = new OptionsModel(); var muexe = new MutationExecutor(options, choices, null); var mucon = new MutantsContainer(muexe, new OriginalCodebase(cci.InList()), new OptionsModel()); var nodes = mucon.InitMutantsForOperators(ProgressCounter.Inactive()); Mutant mutant = nodes.Cast <CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection <CheckedNode>()) .OfType <Mutant>().First();//.Take(4); var cciWhite = new CciModuleSource(filePath); var resu = muexe.ExecuteMutation(mutant, cciWhite).Result; using (var file = File.OpenWrite(filePath)) { resu.MutatedModules.WriteToStream(resu.MutatedModules.Modules.Single(), file, filePath); } var runContext = new NUnitTestsRunContext( options, _kernel.Get <IProcesses>(), _kernel.Get <CommonServices>(), new NUnitResultsParser(), TestProjects.NUnitConsolePath, filePathTests, new TestsSelector()); var testResult = runContext.RunTests().Result; var count = testResult.ResultMethods .GroupBy(t => t.State) .ToDictionary(t => t.Key); var countStrings = count.Select(pair => pair.Key.ToString() + ": " + pair.Value.Count()); _log.Info(string.Format("All test results: " + string.Join(" ", countStrings))); count[TestNodeState.Failure].Count().ShouldEqual(0); }
public void IntegrationTestingMiscUtilLight() { var cci = new CciModuleSource(TestProjects.MiscUtil); var choices = new MutationSessionChoices(); var tt = cci.Module.Module.GetAllTypes(); // var type = (NamedTypeDefinition)cci.Module.Module.GetAllTypes().Single(t => t.Name.Value == "Range"); // var method = new MethodIdentifier(type.Methods.First(m => m.Name.Value == "Contains")); MethodIdentifier method = null; choices.SelectedOperators.Add(new IdentityOperator2()); choices.Filter = method == null ? MutationFilter.AllowAll() : new MutationFilter( new List<TypeIdentifier>(), method.InList()); var options = new OptionsModel(); var muexe = new MutationExecutor(options, choices, null); var mucon = new MutantsContainer(muexe, new OriginalCodebase(cci.InList())); var nodes = mucon.InitMutantsForOperators(ProgressCounter.Inactive()); Mutant mutant = nodes.Cast<CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection<CheckedNode>()) .OfType<Mutant>().First();//.Take(4); var cciWhite = new CciModuleSource(TestProjects.MiscUtil); var resu = muexe.ExecuteMutation(mutant, cciWhite).Result; string filePath = @"C:\PLIKI\VisualMutator\testprojects\MiscUtil-Integration-Tests\TestGround\MiscUtil.dll"; string filePathTests = @"C:\PLIKI\VisualMutator\testprojects\MiscUtil-Integration-Tests\TestGround\MiscUtil.UnitTests.dll"; using (var file = File.OpenWrite(filePath)) { resu.MutatedModules.WriteToStream(resu.MutatedModules.Modules.Single(), file, filePath); } var runContext = new NUnitTestsRunContext( options, _kernel.Get<IProcesses>(), _kernel.Get<CommonServices>(), new NUnitResultsParser(), TestProjects.NUnitConsolePath, filePathTests, new TestsSelector()); var testResult = runContext.RunTests().Result; var count = testResult.ResultMethods .GroupBy(t => t.State) .ToDictionary(t => t.Key); var countStrings = count.Select(pair => pair.Key.ToString() + ": " + pair.Value.Count()); _log.Info(string.Format("All test results: " + string.Join(" ", countStrings))); count[TestNodeState.Failure].Count().ShouldEqual(0); }
public void IntegrationTestMutation() { var cci = new CciModuleSource(TestProjects.MiscUtil); var original = new OriginalCodebase(cci.InList()); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Adler32") as NamedTypeDefinition; var method = type.Methods.First(m => m.Name.Value == "ComputeChecksum"); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List <TypeIdentifier>(), new MethodIdentifier(method).InList()), SelectedOperators = new LOR_LogicalOperatorReplacement().InList <IMutationOperator>(), }; var exec = new MutationExecutor(new OptionsModel(), choices, null); var container = new MutantsContainer(exec, original, new OptionsModel()); IList <AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mutants = assemblies.Cast <CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection <CheckedNode>()) .OfType <Mutant>(); var diff = new CodeDifferenceCreator(); var vis = new CodeVisualizer(original, diff); foreach (var mutant in mutants) { var copy = new CciModuleSource(TestProjects.MiscUtil); MutationResult result = exec.ExecuteMutation(mutant, copy).Result; CodeWithDifference differenceListing = vis.CreateDifferenceListing(CodeLanguage.CSharp, mutant, result).Result; differenceListing.LineChanges.Count.ShouldEqual(2); } }
public void Test00() { const string code = @"using System; namespace Ns { public class Test { public int Method1(int a, int b) { return a + b; } } }"; var cci = new CciModuleSource(TestProjects.DsaPath); var cci2 = new CciModuleSource(TestProjects.DsaPath); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Deque") as NamedTypeDefinition; var method = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); var cci3 = MutationTestsHelper.CreateModuleFromCode(code); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List <TypeIdentifier>(), new MethodIdentifier(method).InList()), //Filter = MutationFilter.AllowAll(), SelectedOperators = new AOR_ArithmeticOperatorReplacement().InList <IMutationOperator>(), }; // var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Test") as NamedTypeDefinition; // var method = type.Methods.Single(m => m.Name.Value == "Method1"); var exec = new MutationExecutor(null, choices, null); var container = new MutantsContainer(exec, new OriginalCodebase(cci.InList()), new OptionsModel()); IList <AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mut = assemblies.Cast <CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection <CheckedNode>()) .OfType <Mutant>().ElementAt(4); MutationResult executeMutation = exec.ExecuteMutation(mut, cci2).Result; var c = new CodeDeepCopier(cci.Host); MethodDefinition methodDefinition = c.Copy(mut.MutationTarget.MethodRaw); var vis = new CodeVisualizer(null, null); var s = vis.Visualize(CodeLanguage.CSharp, cci2); var v = new MutantsCache.Viss(cci2.Host, methodDefinition); var modClean = v.Rewrite(cci2.Modules.Single().Module); cci2.ReplaceWith(modClean); var debug = new DebugOperatorCodeVisitor(); var debug2 = new DebugOperatorCodeVisitor(); new DebugCodeTraverser(debug).Traverse(cci.Modules.Single().Module); new DebugCodeTraverser(debug2).Traverse(cci2.Modules.Single().Module); File.WriteAllText(@"C:\PLIKI\tree1.txt", debug.ToString()); File.WriteAllText(@"C:\PLIKI\tree2.txt", debug2.ToString()); // Console.WriteLine(debug); // Console.WriteLine(debug2); // cci.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); // var s2 = vis.Visualize(CodeLanguage.CSharp, cci2); // Console.WriteLine(s); // Console.WriteLine(s2); // var viss = new Viss(cci2.Host, sourceMethod); // IModule newMod = viss.Rewrite(executeMutation.MutatedModules.Modules.Single().Module); // cci2.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); // MutationResult executeMutation2 = exec.ExecuteMutation(mut, cci2).Result; }
public void Test00() { const string code = @"using System; namespace Ns { public class Test { public int Method1(int a, int b) { return a + b; } } }"; var cci = new CciModuleSource(TestProjects.DsaPath); var cci2 = new CciModuleSource(TestProjects.DsaPath); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Deque") as NamedTypeDefinition; var method = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); var cci3 = MutationTestsHelper.CreateModuleFromCode(code); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List<TypeIdentifier>(), new MethodIdentifier(method).InList()), //Filter = MutationFilter.AllowAll(), SelectedOperators = new AOR_ArithmeticOperatorReplacement().InList<IMutationOperator>(), }; // var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Test") as NamedTypeDefinition; // var method = type.Methods.Single(m => m.Name.Value == "Method1"); var exec = new MutationExecutor(null, choices, null); var container = new MutantsContainer(exec, new OriginalCodebase(cci.InList(), new List<string>())); IList<AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mut = assemblies.Cast<CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection<CheckedNode>()) .OfType<Mutant>().ElementAt(4); MutationResult executeMutation = exec.ExecuteMutation(mut, cci2).Result; var c = new CodeDeepCopier(cci.Host); MethodDefinition methodDefinition = c.Copy(mut.MutationTarget.MethodRaw); var vis = new CodeVisualizer(null, null); var s = vis.Visualize(CodeLanguage.CSharp, cci2); var v = new MutantsCache.Viss(cci2.Host, methodDefinition); var modClean = v.Rewrite(cci2.Modules.Single().Module); cci2.ReplaceWith(modClean); var debug = new DebugOperatorCodeVisitor(); var debug2 = new DebugOperatorCodeVisitor(); new DebugCodeTraverser(debug).Traverse(cci.Modules.Single().Module); new DebugCodeTraverser(debug2).Traverse(cci2.Modules.Single().Module); File.WriteAllText(@"C:\PLIKI\tree1.txt", debug.ToString()); File.WriteAllText(@"C:\PLIKI\tree2.txt", debug2.ToString()); // Console.WriteLine(debug); // Console.WriteLine(debug2); // cci.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); // var s2 = vis.Visualize(CodeLanguage.CSharp, cci2); // Console.WriteLine(s); // Console.WriteLine(s2); // var viss = new Viss(cci2.Host, sourceMethod); // IModule newMod = viss.Rewrite(executeMutation.MutatedModules.Modules.Single().Module); // cci2.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); // MutationResult executeMutation2 = exec.ExecuteMutation(mut, cci2).Result; }
public void Test0() { var cci = new CciModuleSource(TestProjects.DsaPath); var cci2 = new CciModuleSource(TestProjects.DsaPath); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Deque") as NamedTypeDefinition; var method = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List<TypeIdentifier>(), new MethodIdentifier(method).InList()), SelectedOperators = new AOR_ArithmeticOperatorReplacement().InList<IMutationOperator>(), }; var exec = new MutationExecutor(null, choices, null); var container = new MutantsContainer(exec, new OriginalCodebase(cci.InList(), new List<string>())); IList<AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mut = assemblies.Cast<CheckedNode>() .SelectManyRecursive(n => n.Children?? new NotifyingCollection<CheckedNode>()) .OfType<Mutant>().First(); var sourceMethod = type.Methods.Single(m => m.Name.Value == "EnqueueFront"); MutationResult executeMutation = exec.ExecuteMutation(mut, cci2).Result; // var viss = new Viss(cci2.Host, sourceMethod); // IModule newMod = viss.Rewrite(executeMutation.MutatedModules.Modules.Single().Module); cci2.ReplaceWith(executeMutation.MutatedModules.Modules.Single().Module); MutationResult executeMutation2 = exec.ExecuteMutation(mut, cci2).Result; }
public void IntegrationTestMutation() { var cci = new CciModuleSource(TestProjects.MiscUtil); var original = new OriginalCodebase(cci.InList()); var type = cci.Modules.Single().Module.GetAllTypes().Single(t => t.Name.Value == "Adler32") as NamedTypeDefinition; var method = type.Methods.First(m => m.Name.Value == "ComputeChecksum"); var choices = new MutationSessionChoices { Filter = new MutationFilter( new List<TypeIdentifier>(), new MethodIdentifier(method).InList()), SelectedOperators = new LOR_LogicalOperatorReplacement().InList<IMutationOperator>(), }; var exec = new MutationExecutor(new OptionsModel(), choices, null); var container = new MutantsContainer(exec, original); IList<AssemblyNode> assemblies = container.InitMutantsForOperators(ProgressCounter.Inactive()); var mutants = assemblies.Cast<CheckedNode>() .SelectManyRecursive(n => n.Children ?? new NotifyingCollection<CheckedNode>()) .OfType<Mutant>(); var diff = new CodeDifferenceCreator(); var vis = new CodeVisualizer(original, diff); foreach (var mutant in mutants) { var copy = new CciModuleSource(TestProjects.MiscUtil); MutationResult result = exec.ExecuteMutation(mutant, copy).Result; CodeWithDifference differenceListing = vis.CreateDifferenceListing(CodeLanguage.CSharp, mutant, result).Result; differenceListing.LineChanges.Count.ShouldEqual(2); } }