Example #1
0
        public void ReporterFactory_CreatesRequestedReporters(string option, Type reporter)
        {
            BroadcastReporter result = (BroadcastReporter)ReporterFactory.Create(new StrykerOptions(reporters: new[] { option }));

            result.ShouldBeOfType(typeof(BroadcastReporter));
            result.Reporters.ShouldHaveSingleItem().ShouldBeOfType(reporter);
        }
        public void BroadcastReporter_ShouldInvokeAllReportersInList()
        {
            var reporterMock = new Mock <IReporter>(MockBehavior.Strict);

            reporterMock.Setup(x => x.OnAllMutantsTested(It.IsAny <IReadOnlyProjectComponent>()));
            reporterMock.Setup(x => x.OnMutantsCreated(It.IsAny <IReadOnlyProjectComponent>()));
            reporterMock.Setup(x => x.OnMutantTested(It.IsAny <Mutant>()));

            var exampleInputComponent = new ReadOnlyFileLeaf(new FileLeaf());
            var exampleMutant         = new Mutant();

            var reporters = new Collection <IReporter>()
            {
                reporterMock.Object,
                reporterMock.Object
            };
            var target = new BroadcastReporter(reporters);

            target.OnAllMutantsTested(exampleInputComponent);
            target.OnMutantsCreated(exampleInputComponent);
            target.OnMutantTested(exampleMutant);

            reporterMock.Verify(x => x.OnAllMutantsTested(exampleInputComponent), Times.Exactly(2));
            reporterMock.Verify(x => x.OnMutantsCreated(exampleInputComponent), Times.Exactly(2));
            reporterMock.Verify(x => x.OnMutantTested(exampleMutant), Times.Exactly(2));
        }
Example #3
0
        public void ReporterFactory_CreatesReplacementsForDeprecatedReporterOptions()
        {
            BroadcastReporter result = (BroadcastReporter)ReporterFactory.Create(new StrykerOptions(reporters: new[] { "ConsoleProgressBar", "ConsoleProgressDots", "ConsoleReport" }));

            result.ShouldBeOfType(typeof(BroadcastReporter));
            result.Reporters.ShouldContain(r => r is ConsoleDotProgressReporter);
            result.Reporters.ShouldContain(r => r is ClearTextReporter);
            result.Reporters.ShouldContain(r => r is ProgressReporter);
        }
        public void ReporterFactory_CreatesAllReporters()
        {
            BroadcastReporter result = (BroadcastReporter)ReporterFactory.Create(new StrykerOptions(reporters: new[] { "All" }));

            result.ShouldBeOfType(typeof(BroadcastReporter));
            result.Reporters.ShouldContain(r => r is JsonReporter);
            result.Reporters.ShouldContain(r => r is ConsoleDotProgressReporter);
            result.Reporters.ShouldContain(r => r is ConsoleReportReporter);
            result.Reporters.ShouldContain(r => r is ProgressReporter);
        }
        public void BroadcastReporter_NoReportersInList()
        {
            var reporters = new Collection <IReporter>()
            {
            };

            var exampleInputComponent = new ReadOnlyFileLeaf(new FileLeaf());
            var exampleMutant         = new Mutant();

            var target = new BroadcastReporter(reporters);

            target.OnAllMutantsTested(exampleInputComponent);
            target.OnMutantsCreated(exampleInputComponent);
            target.OnMutantTested(exampleMutant);
        }
        public void ReporterFactory_CreatesAllReporters()
        {
            BroadcastReporter result = (BroadcastReporter)ReporterFactory.Create(new StrykerOptions(reporters: new[] { "All" }));

            result.ShouldBeOfType(typeof(BroadcastReporter));
            result.Reporters.ShouldContain(r => r is JsonReporter);
            result.Reporters.ShouldContain(r => r is HtmlReporter);
            result.Reporters.ShouldContain(r => r is ConsoleDotProgressReporter);
            result.Reporters.ShouldContain(r => r is ClearTextReporter);
            result.Reporters.ShouldContain(r => r is ProgressReporter);
            result.Reporters.ShouldContain(r => r is DashboardReporter);
            result.Reporters.ShouldContain(r => r is GitBaselineReporter);

            result.Reporters.Count().ShouldBe(7);
        }
        public void BroadcastReporter_ShouldInvokeSameMethodWithSameObject_OnMutantTested()
        {
            var reporterMock = new Mock <IReporter>(MockBehavior.Strict);

            reporterMock.Setup(x => x.OnMutantTested(It.IsAny <Mutant>()));

            var exampleInputComponent = new FileLeaf();
            var exampleMutant         = new Mutant();

            var reporters = new Collection <IReporter>()
            {
                reporterMock.Object
            };
            var target = new BroadcastReporter(reporters);

            target.OnMutantTested(exampleMutant);

            reporterMock.Verify(x => x.OnMutantTested(exampleMutant), Times.Once);
        }