Beispiel #1
0
        public void TestEvent3()
        {
            // ARRANGE
            DashboardEventRaw data = JsonConvert.DeserializeObject <DashboardEventRaw>(File.ReadAllText("test-event-3.json"));

            // ACT
            EventTimeline startEnd = EventTimelineUtilities.GetEventTimeline(data);

            // ASSERT
            Assert.Equal(new DateTime(2019, 4, 25, 16, 11, 0, DateTimeKind.Utc), startEnd.Start);
            Assert.Equal(new DateTime(2019, 4, 25, 19, 13, 0, DateTimeKind.Utc), startEnd.End);
        }
Beispiel #2
0
        public void SimpleBetweenXandYRegex()
        {
            // ARRANGE
            // Tue May 15 2018 15:12:21 GMT+0000
            // Between 5:27 AM and 8:17 AM PDT, 7 hours difference
            DateTime start = new DateTime(2018, 5, 15, 12, 27, 0, DateTimeKind.Utc);
            DateTime end   = new DateTime(2018, 5, 15, 15, 17, 0, DateTimeKind.Utc);

            DashboardEventRaw ev = JsonConvert.DeserializeObject <DashboardEventRaw>(File.ReadAllText("ec2-us-east-1.json"));

            // ACT
            EventTimeline startEnd = EventTimelineUtilities.GetEventTimeline(ev);

            // ASSERT
            Assert.Equal(start, startEnd.Start);
            Assert.Equal(end, startEnd.End);
        }
Beispiel #3
0
        public void ComplexBetweenXandY()
        {
            // ARRANGE
            // Wed Aug 08 2018 10:02:04 GMT+0000
            // Between 5:10 PM on August 7th, and 3:50 AM PDT on August 8th, 7 hours difference
            DateTime start = new DateTime(2018, 8, 8, 0, 10, 0, DateTimeKind.Utc);
            DateTime end   = new DateTime(2018, 8, 8, 10, 50, 0, DateTimeKind.Utc);

            DashboardEventRaw ev = JsonConvert.DeserializeObject <DashboardEventRaw>(File.ReadAllText("emr-ap-south-1.json"));

            // ACT
            EventTimeline startEnd = EventTimelineUtilities.GetEventTimeline(ev);

            // ASSERT
            Assert.Equal(start, startEnd.Start);
            Assert.Equal(end, startEnd.End);
        }
Beispiel #4
0
        public void TestAllData()
        {
            // ARRANGE
            DashboardEventData data = JsonConvert.DeserializeObject <DashboardEventData>(File.ReadAllText("data.json"));

            File.WriteAllText("misses.json", "[");

            int success   = 0;
            int unhandled = 0;

            List <EventTimeline> timelines = new List <EventTimeline>();

            // ACT
            foreach (DashboardEventRaw ev in data.Archive)
            {
                try
                {
                    EventTimeline evTimeline = EventTimelineUtilities.GetEventTimeline(ev);
                    timelines.Add(evTimeline);
                    success += 1;

                    if (evTimeline.EndTimeWasFoundInDescription == false)
                    {
                        File.AppendAllText("misses.json", JsonConvert.SerializeObject(ev));
                    }
                }
                catch (Exception e)
                {
                    unhandled += 1;
                }
            }

            File.AppendAllText("misses.json", "]");

            // ASSERT
            Assert.Equal(data.Archive.Count(), success);
            Assert.Equal(0, unhandled);
        }