예제 #1
0
        public void ReadPartyMember(PartyMember partyMember,
                                    IDataReader dataReader, IDataReader partyTextReader,
                                    IDataReader fallbackDataReader = null)
        {
            ReadCharacter(partyMember, dataReader);
            int eventOffset = dataReader.Position;

            try
            {
                EventReader.ReadEvents(dataReader, partyMember.Events, partyMember.EventList);
            }
            catch
            {
                if (fallbackDataReader == null)
                {
                    throw;
                }

                // Events were messed up on writing but we can load them from initial save eventually.
                partyMember.EventList.Clear();
                partyMember.Events.Clear();
                fallbackDataReader.Position = eventOffset;
                EventReader.ReadEvents(fallbackDataReader, partyMember.Events, partyMember.EventList);
                System.Console.WriteLine("Fixed corrupted savegame");
            }
            partyMember.Texts = partyTextReader == null ? new List <string>() : TextReader.ReadTexts(partyTextReader);
        }
        public void ShouldReadAllItemsFromGivenLog()
        {
            SetupEvents(1000, EventLogEntryType.Error);
            SetupEvents(1000, EventLogEntryType.Warning);
            SetupEvents(1000, EventLogEntryType.Information);
            SetupEvents(100, EventLogEntryType.SuccessAudit);
            SetupEvents(100, EventLogEntryType.FailureAudit);

            EventReader reader = new EventReader(_testEventLog, TimeSpan.FromHours(1));

            List <LogEvent> events = new List <LogEvent>(reader.ReadEvents());

            Assert.That(events.Count(), Is.EqualTo(3200));
        }
        public void ShouldReadAllFieldsFromEvent()
        {
            const int    eventId    = 32456;
            const int    categoryId = 32;
            const string message    = "An error occurred!!!";

            _testEventLog.WriteEntry(message, EventLogEntryType.Error, eventId, categoryId);

            var reader = new EventReader(_testEventLog, TimeSpan.FromMinutes(1));
            var events = reader.ReadEvents();

            Assert.That(events.Count(), Is.EqualTo(1));
            var firstEvent = events.First();

            Assert.That(firstEvent.ErrorLevel, Is.EqualTo(2)); // == EventLogEntryType.Error
            Assert.That(firstEvent.EventID, Is.EqualTo(eventId));
            Assert.That(firstEvent.CategoryNumber, Is.EqualTo(categoryId));
            Assert.That(firstEvent.Message, Is.EqualTo(message));
            Assert.That(firstEvent.EntryType, Is.EqualTo(EventLogEntryType.Error));
            Assert.That(firstEvent.InstanceID, Is.EqualTo(eventId));
            Assert.That(firstEvent.Source, Is.EqualTo(_testEventLog.Source));
            Assert.That(firstEvent.TimeGenerated, Is.EqualTo(DateTime.Now).Within(TimeSpan.FromSeconds(10)));
        }
예제 #4
0
 public void ReadNPC(NPC npc, IDataReader dataReader, IDataReader npcTextReader)
 {
     ReadCharacter(npc, dataReader);
     EventReader.ReadEvents(dataReader, npc.Events, npc.EventList);
     npc.Texts = TextReader.ReadTexts(npcTextReader);
 }