Exemple #1
0
        public void MutantFilterFactory_Creates_ExcludeLinqExpressionFilter_When_ExcludedLinqExpressions_IsNotEmpty()
        {
            // Arrange
            var options = new StrykerOptions()
            {
                ExcludedLinqExpressions = new List <LinqExpression>()
                {
                    LinqExpression.Any
                }
            };

            var diffProviderMock   = new Mock <IDiffProvider>(MockBehavior.Loose);
            var branchProviderMock = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProvider   = new Mock <IBaselineProvider>(MockBehavior.Loose);

            // Act
            var result = MutantFilterFactory.Create(options, null, diffProviderMock.Object, baselineProvider.Object, branchProviderMock.Object);

            // Assert
            var resultAsBroadcastFilter = result.ShouldBeOfType <BroadcastMutantFilter>();

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(5);

            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(ExcludeLinqExpressionFilter)).Count().ShouldBe(1);
        }
        public void MutantFilterFactory_Creates_of_type_BroadcastFilter()
        {
            var diffProviderMock   = new Mock <IDiffProvider>(MockBehavior.Loose);
            var branchProviderMock = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProvider   = new Mock <IBaselineProvider>(MockBehavior.Loose);

            var result = MutantFilterFactory.Create(new StrykerOptions(diff: false), diffProviderMock.Object, baselineProvider.Object, branchProviderMock.Object);

            result.ShouldBeOfType <BroadcastMutantFilter>();
        }
        public void MutantFilterFactory_Creates_Standard_Mutant_Filters()
        {
            // Arrange
            var strykerOptions = new StrykerOptions(diff: false);

            // Act
            var result = MutantFilterFactory.Create(strykerOptions);

            // Assert
            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(4);
        }
        public void MutantFilterFactory_Creates_DashboardMutantFilter_And_DiffMutantFilter_Dashboard_Compare_Enabled()
        {
            var strykerOptions = new StrykerOptions(compareToDashboard: true, projectVersion: "foo");

            var diffProviderMock     = new Mock <IDiffProvider>(MockBehavior.Loose);
            var gitInfoProviderMock  = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProviderMock = new Mock <IBaselineProvider>(MockBehavior.Loose);

            var result = MutantFilterFactory.Create(strykerOptions, diffProviderMock.Object, baselineProviderMock.Object, gitInfoProviderMock.Object);

            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(6);
            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(DashboardMutantFilter)).Count().ShouldBe(1);
            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(DiffMutantFilter)).Count().ShouldBe(1);
        }
Exemple #5
0
        public CsharpMutationProcess(MutationTestInput mutationTestInput,
                                     IFileSystem fileSystem     = null,
                                     StrykerOptions options     = null,
                                     IMutantFilter mutantFilter = null,
                                     BaseMutantOrchestrator <SyntaxNode> orchestrator = null)
        {
            _input            = mutationTestInput;
            _projectInfo      = (ProjectComponent <SyntaxTree>)mutationTestInput.ProjectInfo.ProjectContents;
            _options          = options;
            _orchestrator     = orchestrator ?? new CsharpMutantOrchestrator(options: _options);
            _compilingProcess = new CsharpCompilingProcess(mutationTestInput, new RollbackProcess());
            _fileSystem       = fileSystem ?? new FileSystem();
            _logger           = ApplicationLogging.LoggerFactory.CreateLogger <MutationTestProcess>();

            _mutantFilter = mutantFilter ?? MutantFilterFactory.Create(options, _input);
        }
        public void MutantFilterFactory_Creates_Standard_Mutant_Filters()
        {
            // Arrange
            var strykerOptions = new StrykerOptions(diff: false);

            var diffProviderMock   = new Mock <IDiffProvider>(MockBehavior.Loose);
            var branchProviderMock = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProvider   = new Mock <IBaselineProvider>(MockBehavior.Loose);

            // Act
            var result = MutantFilterFactory.Create(strykerOptions, diffProviderMock.Object, baselineProvider.Object, branchProviderMock.Object);

            // Assert
            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(4);
        }
        public void MutantFilterFactory_Creates_DiffMutantFilter_When_Diff_Enabled()
        {
            // Arrange
            var strykerOptions = new StrykerOptions(diff: true);

            var diffProviderMock = new Mock <IDiffProvider>(MockBehavior.Loose);

            // Act
            var result = MutantFilterFactory.Create(strykerOptions, diffProviderMock.Object);

            // Assert
            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(5);

            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(DiffMutantFilter)).Count().ShouldBe(1);
        }
Exemple #8
0
 public MutationTestProcess(MutationTestInput mutationTestInput,
                            IReporter reporter,
                            IMutationTestExecutor mutationTestExecutor,
                            IMutantOrchestrator orchestrator   = null,
                            ICompilingProcess compilingProcess = null,
                            IFileSystem fileSystem             = null,
                            StrykerOptions options             = null,
                            IMutantFilter mutantFilter         = null)
 {
     _input                = mutationTestInput;
     _reporter             = reporter;
     _options              = options;
     _mutationTestExecutor = mutationTestExecutor;
     _orchestrator         = orchestrator ?? new MutantOrchestrator(options: _options);
     _compilingProcess     = compilingProcess ?? new CompilingProcess(mutationTestInput, new RollbackProcess());
     _fileSystem           = fileSystem ?? new FileSystem();
     _logger               = ApplicationLogging.LoggerFactory.CreateLogger <MutationTestProcess>();
     _mutantFilter         = mutantFilter ?? MutantFilterFactory.Create(options);
 }
Exemple #9
0
        public void MutantFilterFactory_Creates_DashboardMutantFilter_And_DiffMutantFilter_WithBaseline_Enabled()
        {
            var options = new StrykerOptions()
            {
                WithBaseline   = true,
                ProjectVersion = "foo"
            };

            var diffProviderMock     = new Mock <IDiffProvider>(MockBehavior.Loose);
            var gitInfoProviderMock  = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProviderMock = new Mock <IBaselineProvider>(MockBehavior.Loose);

            var result = MutantFilterFactory.Create(options, null, diffProviderMock.Object, baselineProviderMock.Object, gitInfoProviderMock.Object);

            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(6);
            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(BaselineMutantFilter)).Count().ShouldBe(1);
            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(SinceMutantFilter)).Count().ShouldBe(1);
        }
Exemple #10
0
        public void MutantFilterFactory_Creates_DiffMutantFilter_When_Since_Enabled()
        {
            // Arrange
            var options = new StrykerOptions()
            {
                Since = true
            };

            var diffProviderMock   = new Mock <IDiffProvider>(MockBehavior.Loose);
            var branchProviderMock = new Mock <IGitInfoProvider>(MockBehavior.Loose);
            var baselineProvider   = new Mock <IBaselineProvider>(MockBehavior.Loose);

            // Act
            var result = MutantFilterFactory.Create(options, null, diffProviderMock.Object, baselineProvider.Object, branchProviderMock.Object);

            // Assert
            var resultAsBroadcastFilter = result as BroadcastMutantFilter;

            resultAsBroadcastFilter.MutantFilters.Count().ShouldBe(5);

            resultAsBroadcastFilter.MutantFilters.Where(x => x.GetType() == typeof(SinceMutantFilter)).Count().ShouldBe(1);
        }
 public void Create_Throws_ArgumentNullException_When_Stryker_Options_Is_Null()
 {
     var result = Should.Throw <ArgumentNullException>(() => MutantFilterFactory.Create(null));
 }
        public void MutantFilterFactory_Creates_of_type_BroadcastFilter()
        {
            var result = MutantFilterFactory.Create(new StrykerOptions());

            result.ShouldBeOfType <BroadcastMutantFilter>();
        }