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); }