Ejemplo n.º 1
0
        public void WhenErrorAddedThenErrorAvailable()
        {
            const string      expectedFirstMsg        = "test 1";
            const int         expectedFirstErrorCount = 1;
            const int         expectedOutputCount     = 0;
            IFeedbackProvider subject = new FeedbackProvider();

            subject.AddError(expectedFirstMsg);
            Assert.Equal(expectedFirstErrorCount, subject.Errors.Count());
            Assert.Equal(expectedOutputCount, subject.Output.Count());
            Assert.Equal(expectedFirstMsg, subject.Errors.First());
            Assert.Equal(expectedFirstMsg, subject.LastError);

            const string expectedSecondMsg   = "test 2";
            const int    expectedSecondCount = 2;

            subject.AddError(expectedSecondMsg);
            Assert.Equal(expectedSecondCount, subject.Errors.Count());
            Assert.Equal(expectedOutputCount, subject.Output.Count());
            Assert.Equal(expectedSecondMsg, subject.Errors.ToArray()[1]);
            Assert.Equal(expectedSecondMsg, subject.LastError);
        }
Ejemplo n.º 2
0
        public void WhenErrorAddedThenErrorEventRaised()
        {
            const string expectedMsg1             = "test 1";
            const int    expectedNrOfErrorEvents  = 1;
            const int    expectedNrOfOutputEvents = 0;
            int          actualNrOfErrorEvents    = 0;
            int          actualNrOfOutputEvents   = 0;

            IFeedbackProvider subject = new FeedbackProvider();

            subject.ErrorAdded += (sender, msg) =>
            {
                Assert.Same(subject, sender);
                Assert.Equal(expectedMsg1, msg);
                actualNrOfErrorEvents++;
            };

            subject.OutputAdded += (sender, msg) => actualNrOfOutputEvents++;

            subject.AddError(expectedMsg1);
            Assert.Equal(expectedNrOfErrorEvents, actualNrOfErrorEvents);
            Assert.Equal(expectedNrOfOutputEvents, actualNrOfOutputEvents);
        }