Exemple #1
0
        public static void Test(IMediaBasedReaderFactory factory, ILogMedia media, ExpectedLog expectation)
        {
            using (ILogSourceThreadsInternal threads = new LogSourceThreads())
                using (IPositionedMessagesReader reader = factory.CreateMessagesReader(new MediaBasedReaderParams(threads, media, tempFilesManager, new TraceSourceFactory())))
                {
                    reader.UpdateAvailableBounds(false);

                    List <IMessage> msgs = new List <IMessage>();

                    using (var parser = reader.CreateParser(new CreateParserParams(reader.BeginPosition)))
                    {
                        for (; ;)
                        {
                            var msg = parser.ReadNext();
                            if (msg == null)
                            {
                                break;
                            }
                            msgs.Add(msg);
                        }
                    }

                    expectation.StartVerification();
                    for (int i = 0; i < msgs.Count; ++i)
                    {
                        expectation.Verify(i, msgs[i]);
                    }
                    expectation.FinishVerification();
                }
        }
        public static async Task Test(IMediaBasedReaderFactory factory, ILogMedia media, ExpectedLog expectation)
        {
            using (ILogSourceThreadsInternal threads = new LogSourceThreads())
                using (IPositionedMessagesReader reader = factory.CreateMessagesReader(new MediaBasedReaderParams(threads, media)))
                {
                    await reader.UpdateAvailableBounds(false);

                    List <IMessage> msgs = new List <IMessage>();

                    await DisposableAsync.Using(await reader.CreateParser(new CreateParserParams(reader.BeginPosition)), async parser =>
                    {
                        for (; ;)
                        {
                            var msg = await parser.ReadNext();
                            if (msg == null)
                            {
                                break;
                            }
                            msgs.Add(msg);
                        }
                    });

                    expectation.StartVerification();
                    for (int i = 0; i < msgs.Count; ++i)
                    {
                        expectation.Verify(i, msgs[i]);
                    }
                    expectation.FinishVerification();
                }
        }
        public static void Test(IMediaBasedReaderFactory factory, ILogMedia media, ExpectedLog expectation)
        {
            using (ILogSourceThreads threads = new LogSourceThreads())
                using (IPositionedMessagesReader reader = factory.CreateMessagesReader(new MediaBasedReaderParams(threads, media, tempFilesManager)))
                {
                    reader.UpdateAvailableBounds(false);

                    List <IMessage> msgs = new List <IMessage>();

                    using (var parser = reader.CreateParser(new CreateParserParams(reader.BeginPosition)))
                    {
                        for (; ;)
                        {
                            var msg = parser.ReadNext();
                            if (msg == null)
                            {
                                break;
                            }
                            msgs.Add(msg);
                        }
                    }

                    expectation.StartVerification();
                    int frameLevel = 0;
                    for (int i = 0; i < msgs.Count; ++i)
                    {
                        switch (msgs[i].Flags & MessageFlag.TypeMask)
                        {
                        case MessageFlag.StartFrame:
                            ++frameLevel;
                            break;

                        case MessageFlag.EndFrame:
                            --frameLevel;
                            break;
                        }

                        expectation.Verify(i, msgs[i], frameLevel);
                    }
                    expectation.FinishVerification();
                }
        }