Exemplo n.º 1
0
        public void ReadsJournalEntriesFromAJournalFile()
        {
            var file = Path.GetFullPath(Path.Combine(_jf.FullName, _journalFile1));

            var entries = new List <JournalEntry>();

            using (var jr = new JournalReader(file))
            {
                Assert.Equal(file, jr.Name);

                JournalEntry entry;
                while ((entry = jr.ReadEntry()) != null)
                {
                    entries.Add(entry);
                }
            }

            Assert.Equal(5, entries.Count);
            Assert.IsType <FileHeader>(entries[0]);
            Assert.IsType <Music>(entries[1]);
            Assert.IsType <StartJump>(entries[2]);
            Assert.IsType <JournalEntry>(entries[3]);
            Assert.IsType <Shutdown>(entries[4]);
            Assert.Equal("AdditionalValue1", entries[4].AdditionalFields["AdditionalField1"]);
        }
Exemplo n.º 2
0
        public void ReaderThrowsOnAJournalEntryBiggerThanTheInternalBuffer()
        {
            using var dir = new TestFolder();
            var file = "Journal.entry-too-big.log";
            var body = $"{{ \"event\":\"One\" }}\r\n{{ \"event\":\"{new string('A', 33000)}\" }}\r\n";

            dir.WriteText(file, body);

            using var jr = new JournalReader(dir.Resolve(file));
            var entry = jr.ReadEntry();

            Assert.Equal("One", entry.Event);

            var ex = Assert.Throws <InvalidDataException>(() => jr.ReadEntry());

            Assert.Equal("Entry too large found in journal 'Journal.entry-too-big.log' at position 19.", ex.Message);
        }
Exemplo n.º 3
0
        public void ReadsJournalEntriesFromAJournalFile()
        {
            var file = Path.GetFullPath(Path.Combine(_jf.FullName, _journalFile1));

            var entries = new Queue <JournalEntry>();

            using (var jr = new JournalReader(file))
            {
                Assert.Equal(file, jr.Name);

                JournalEntry entry;
                while ((entry = jr.ReadEntry()) != null)
                {
                    entries.Enqueue(entry);
                }
            }

            Assert.Equal(_journalFile1Count, entries.Count);

            var fh = Assert.IsType <FileHeader>(entries.Dequeue());

            Assert.Equal(1, fh.Part);
            Assert.Equal("English\\UK", fh.Language);
            Assert.Equal("3.5.0.200 EDH", fh.GameVersion);
            Assert.Equal("r210198/r0 ", fh.Build);

            var mu = Assert.IsType <Music>(entries.Dequeue());

            Assert.Equal("NoTrack", mu.MusicTrack);

            var ua = Assert.IsType <UnderAttack>(entries.Dequeue());

            Assert.Equal(UnderAttack.AttackTarget.You, ua.Target);

            var sj = Assert.IsType <StartJump>(entries.Dequeue());

            Assert.Equal(StartJump.FsdJumpType.Hyperspace, sj.JumpType);
            Assert.Equal("Wolf 1301", sj.StarSystem);
            Assert.Equal(1458242032322, sj.SystemAddress);
            Assert.Equal("G", sj.StarClass);

            Assert.IsType <JournalEntry>(entries.Dequeue());

            var sd = Assert.IsType <Shutdown>(entries.Dequeue());

            Assert.Equal(new DateTimeOffset(2019, 1, 1, 0, 19, 4, TimeSpan.Zero), sd.Timestamp);
            Assert.Equal("AdditionalValue1", sd.AdditionalFields["AdditionalField1"]);
        }
Exemplo n.º 4
0
        public void ReadsJournalEntriesFromAJournalFile()
        {
            var file = Path.GetFullPath(Path.Combine(_jf.FullName, _journalFile1));

            var entries = new List <JournalEntry>();

            using (var jr = new JournalReader(file))
            {
                Assert.Equal(file, jr.Name);

                JournalEntry entry;
                while ((entry = jr.ReadEntry()) != null)
                {
                    entries.Add(entry);
                }
            }

            Assert.Equal(5, entries.Count);

            var e0 = Assert.IsType <FileHeader>(entries[0]);

            Assert.Equal(1, e0.Part);
            Assert.Equal("English\\UK", e0.Language);
            Assert.Equal("3.5.0.200 EDH", e0.GameVersion);
            Assert.Equal("r210198/r0 ", e0.Build);

            var e1 = Assert.IsType <Music>(entries[1]);

            Assert.Equal("NoTrack", e1.MusicTrack);

            var e2 = Assert.IsType <StartJump>(entries[2]);

            Assert.Equal(StartJump.FsdJumpType.Hyperspace, e2.JumpType);
            Assert.Equal("Wolf 1301", e2.StarSystem);
            Assert.Equal(1458242032322, e2.SystemAddress);
            Assert.Equal("G", e2.StarClass);

            Assert.IsType <JournalEntry>(entries[3]);
            Assert.IsType <Shutdown>(entries[4]);
            Assert.Equal(new DateTimeOffset(2019, 1, 1, 0, 19, 4, TimeSpan.Zero), entries[4].Timestamp);
            Assert.Equal("AdditionalValue1", entries[4].AdditionalFields["AdditionalField1"]);
        }