Exemplo n.º 1
0
        public void ReportError_WithAllParameters_CallsWriteErrorOnOutputter()
        {
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError("message", new { test = "" }, new { test = "tester" });

            mockOutputter.Received(1).WriteError(Arg.Any<string>(), Arg.Any<object[]>());
        }
Exemplo n.º 2
0
        public void ReportError_WithAllParameters_ErrorIsAdded()
        {
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError("message", new { test = "" }, new { test = "tester" });

            Assert.NotEmpty(reporter.Errors);
        }
Exemplo n.º 3
0
        public void ReportError_WithNoParameters_ErrorIsAdded()
        {
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError();

            Assert.NotEmpty(reporter.Errors);
        }
Exemplo n.º 4
0
        public void ReportError_WithOnlyErrorMessageParameters_ErrorIsAdded()
        {
            var errorMessage = "My error message about something that went wrong";
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError(errorMessage);

            Assert.NotEmpty(reporter.Errors);
            Assert.Equal(errorMessage, reporter.Errors.First());
        }
Exemplo n.º 5
0
        public void ThrowIfAnyErrors_WithErrors_ThrowsPactFailureException()
        {
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError("something broke");

            Assert.Throws<PactFailureException>(() => reporter.ThrowIfAnyErrors());
        }
Exemplo n.º 6
0
        public void ClearErrors_WithErrors_ErrorsIsEmpty()
        {
            var mockOutputter = Substitute.For<IReportOutputter>();
            var reporter = new Reporter(mockOutputter);

            reporter.ReportError("something broke");
            reporter.ReportError("something broke 2");

            reporter.ClearErrors();

            Assert.Empty(reporter.Errors);
        }