示例#1
0
        private ProfilerWatcher ExpectLog(List<MatchMessageDelegate> expectedMessages)
        {
            var watcher = new ProfilerWatcher(expectedMessages);
            watcher.LogAction = message =>
            {
                var messageToString = message.ToString();
                Console.Out.WriteLine(message.ToString());
                Console.Out.Flush();

                Assert.That(watcher.CurrentMessage < expectedMessages.Count, "Unexpected message received: [{0}]", messageToString);
                string expectedMessage;
                var result = expectedMessages[watcher.CurrentMessage](messageToString, out expectedMessage, false);
                Assert.That(result, "Expecting message [{0}]", expectedMessage);
                watcher.CurrentMessage++;
            };
            GlobalLogger.GlobalMessageLogged += watcher.LogAction;
            return watcher;
        }