Ejemplo n.º 1
0
        public void IntegrationTestingMiscUtil()
        {
            var paths = new[] {
                TestProjects.MiscUtil,
                TestProjects.MiscUtilTests
            }.Select(_ => _.ToFilePathAbs()).ToList();

            var cci      = new CciModuleSource(TestProjects.MiscUtil);
            var cciTests = new CciModuleSource(TestProjects.MiscUtilTests);

            var toMutate = TestProjects.MiscUtil.InList();
            var original = new OriginalCodebase(new List <CciModuleSource> {
                cci, cciTests
            });

            var type   = (NamedTypeDefinition)cci.Module.Module.GetAllTypes().Single(t => t.Name.Value == "Range");
            var method = type.Methods.First(m => m.Name.Value == "Contains");

            var oper = new ROR_RelationalOperatorReplacement().InList <IMutationOperator>();

            var mutants = SetupMutations(original, paths, toMutate, oper, new MethodIdentifier(method));

            var vis = _kernel.Get <ICodeVisualizer>();


            var muma = _kernel.Get <MutantMaterializer>();


            IObserver <SessionEventArgs> sub = new ReplaySubject <SessionEventArgs>();

            foreach (var mutant in mutants)
            {
                //  var copy = new CciModuleSource(TestProjects.MiscUtil);
                //    MutationResult result = exec.ExecuteMutation(mutant, copy).Result;
                var muma2 = _kernel.Get <IFactory <TestingMutant> >().CreateWithParams(sub, mutant);


                var r          = muma2.RunAsync().Result;
                var namespaces = _kernel.Get <TestsContainer>().CreateMutantTestTree(mutant);
                var meth       = namespaces.Cast <CheckedNode>()
                                 .SelectManyRecursive(n => n.Children, leafsOnly: true).OfType <TestNodeMethod>();

                //   vis.CreateDifferenceListing()
                meth.Count(m => m.State == TestNodeState.Failure).ShouldBeGreaterThan(0);
                //  var storedMutantInfo = muma.StoreMutant(mutant).Result;

                //  RunTestsForMutant(_choices.MutantsTestingOptions, _storedMutantInfo);

                //   CodeWithDifference differenceListing = vis.CreateDifferenceListing(CodeLanguage.CSharp, mutant, result).Result;
                //     differenceListing.LineChanges.Count.ShouldEqual(2);
            }
        }
Ejemplo n.º 2
0
        public void IntegrationTestingMiscUtil()
        {
            var paths = new[] {
                 TestProjects.MiscUtil,
                 TestProjects.MiscUtilTests}.Select(_ => _.ToFilePathAbs()).ToList();

            var cci = new CciModuleSource(TestProjects.MiscUtil);
            var cciTests = new CciModuleSource(TestProjects.MiscUtilTests);

            var toMutate = TestProjects.MiscUtil.InList();
            var original = new OriginalCodebase(new List<CciModuleSource> {cci, cciTests});

            var type = (NamedTypeDefinition)cci.Module.Module.GetAllTypes().Single(t => t.Name.Value == "Range");
            var method = type.Methods.First(m => m.Name.Value == "Contains");

            var oper = new ROR_RelationalOperatorReplacement().InList<IMutationOperator>();

            var mutants = SetupMutations(original, paths, toMutate, oper, new MethodIdentifier(method));

            var vis = _kernel.Get<ICodeVisualizer>();


            var muma = _kernel.Get<MutantMaterializer>();


            IObserver<SessionEventArgs> sub = new ReplaySubject<SessionEventArgs>();
            foreach (var mutant in mutants)
            {
                //  var copy = new CciModuleSource(TestProjects.MiscUtil);
                //    MutationResult result = exec.ExecuteMutation(mutant, copy).Result;
                var muma2 = _kernel.Get<IFactory<TestingMutant>>().CreateWithParams(sub, mutant);


                var r = muma2.RunAsync().Result;
                var namespaces = _kernel.Get<TestsContainer>().CreateMutantTestTree(mutant);
                var meth = namespaces.Cast<CheckedNode>()
                    .SelectManyRecursive(n => n.Children, leafsOnly: true).OfType<TestNodeMethod>();

             //   vis.CreateDifferenceListing()
                meth.Count(m => m.State == TestNodeState.Failure).ShouldBeGreaterThan(0);
                //  var storedMutantInfo = muma.StoreMutant(mutant).Result;

                //  RunTestsForMutant(_choices.MutantsTestingOptions, _storedMutantInfo);

                //   CodeWithDifference differenceListing = vis.CreateDifferenceListing(CodeLanguage.CSharp, mutant, result).Result;
                //     differenceListing.LineChanges.Count.ShouldEqual(2);

            }

        }