Example #1
0
        public void WhenOutputAddedThenOutputAvailable()
        {
            const string      expectedFirstMsg         = "test 1";
            const int         expectedFirstOutputCount = 1;
            const int         expectedErrorCount       = 0;
            IFeedbackProvider subject = new FeedbackProvider();

            subject.AddOutput(expectedFirstMsg);
            Assert.Equal(expectedFirstOutputCount, subject.Output.Count());
            Assert.Equal(expectedErrorCount, subject.Errors.Count());
            Assert.Equal(expectedFirstMsg, subject.Output.First());
            Assert.Equal(expectedFirstMsg, subject.LastOutput);

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

            subject.AddOutput(expectedSecondMsg);
            Assert.Equal(expectedSecondOutputCount, subject.Output.Count());
            Assert.Equal(expectedErrorCount, subject.Errors.Count());
            Assert.Equal(expectedSecondMsg, subject.Output.ToArray()[1]);
            Assert.Equal(expectedSecondMsg, subject.LastOutput);
        }
Example #2
0
        public void WhenOutputAddedThenOutputEventRaised()
        {
            const string expectedMsg1 = "test 1";
            const int    expectedNrOfOutputAddedEvents = 1;
            const int    expectedNrOfErrorAddedEvents  = 0;
            int          actualNrOfOutputEvents        = 0;
            int          actualNrOfErrorEvents         = 0;

            IFeedbackProvider subject = new FeedbackProvider();

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

            subject.AddOutput(expectedMsg1);
            Assert.Equal(expectedNrOfOutputAddedEvents, actualNrOfOutputEvents);
            Assert.Equal(expectedNrOfErrorAddedEvents, actualNrOfErrorEvents);
        }