Ejemplo n.º 1
0
        public void Parse_ShouldSendParserSummaryMessageWhenFinishedWithCorrectLineNUmber()
        {
            const int expectedLineNumber = 973;
            var       mockMessageHandler = new Mock <IMessageHandler>();
            var       parser             = new PascalTopDownParser(Mock.Of <IScanner>(scanner => scanner.NextToken() == new EofToken(Mock.Of <ISource>(s => s.LineNumber == expectedLineNumber))), mockMessageHandler.Object, Mock.Of <ITimeProvider>());

            parser.Parse();

            mockMessageHandler.Verify(handler => handler.SendMessage(It.Is <dogma.Message.Message>(m => ((object[])m.Body).SequenceEqual(new object[] { expectedLineNumber, 0L, 0f }))));
        }
Ejemplo n.º 2
0
        public void Parse_ShouldSendParserSummaryMessageWhenFinishedWithCorrectErrorCount()
        {
            const long expectedErrorCount = 0L;
            var        mockMessageHandler = new Mock <IMessageHandler>();
            var        parser             = new PascalTopDownParser(Mock.Of <IScanner>(scanner => scanner.NextToken() == new EofToken(Mock.Of <ISource>())), mockMessageHandler.Object, Mock.Of <ITimeProvider>());

            parser.Parse();

            mockMessageHandler.Verify(handler => handler.SendMessage(It.Is <dogma.Message.Message>(m => ((object[])m.Body).SequenceEqual(new object[] { 0, expectedErrorCount, 0f }))));
        }
Ejemplo n.º 3
0
        public void Parse_ShouldSendParserSummaryMessageWhenFinished()
        {
            const MessageType expectedMessageType = MessageType.PARSER_SUMMARY;
            var mockMessageHandler = new Mock <IMessageHandler>();
            var parser             = new PascalTopDownParser(Mock.Of <IScanner>(scanner => scanner.NextToken() == new EofToken(Mock.Of <ISource>())), mockMessageHandler.Object, Mock.Of <ITimeProvider>());

            parser.Parse();

            mockMessageHandler.Verify(handler => handler.SendMessage(It.Is <dogma.Message.Message>(m => m.Type == expectedMessageType)));
        }
Ejemplo n.º 4
0
        public void Parse_ShouldSendParserSummaryMessageWhenFinishedWithCorrectElapsedTime()
        {
            const float expectedElapsedTime = 10f;
            var         mockMessageHandler  = new Mock <IMessageHandler>();
            var         mockTimeProvider    = new Mock <ITimeProvider>();

            mockTimeProvider.Setup(tp => tp.NowAsUnixTimeMilliseconds()).Returns(1000L);
            mockTimeProvider.Setup(tp => tp.ElapsedTimeSinceInSeconds(1000L)).Returns(expectedElapsedTime);


            var parser = new PascalTopDownParser(Mock.Of <IScanner>(scanner => scanner.NextToken() == new EofToken(Mock.Of <ISource>())), mockMessageHandler.Object, mockTimeProvider.Object);

            parser.Parse();

            mockMessageHandler.Verify(handler => handler.SendMessage(It.Is <dogma.Message.Message>(m => ((object[])m.Body).SequenceEqual(new object[] { 0, 0L, expectedElapsedTime }))));
        }