public void MessageGrouping_SameSource_VerifyGrouping()
        {
            var subject = new MonitorWorkItem(new MonitorConfiguration())
                          .AddMessageGroupingPatterns(ExportIntegrationErrorsStep.MessageGroupingPattern);

            using (TimeReseter.SetUtc(new DateTimeOffset(2015, 06, 13, 12, 00, 00, TimeSpan.Zero)))
            {
                subject.Add(Time.UtcNow.AddHours(-2), "Source", "Message. ErrorID: 1");
                subject.Add(Time.UtcNow.AddHours(-1), "Source", "Message. ErrorID: 2");
                subject.Add(Time.UtcNow, "Source", "Message. ErrorID: 3");

                MonitorEntry[] entries = subject.GetEntries(Target.Service);

                Assert.That(entries.Length, Is.EqualTo(1));
                Assert.That(entries[0].DateTime, Is.EqualTo(Time.UtcNow));
                Assert.That(entries[0].Source, Is.EqualTo("Source"));
                Assert.That(entries[0].Message, Is.EqualTo(string.Join(Environment.NewLine,
                                                                       "Message. ErrorID: 3",
                                                                       string.Empty,
                                                                       "--- Additional similar entries (Total: 3) ---",
                                                                       string.Empty,
                                                                       "ErrorID: 2 (6/13/2015 11:00:00 AM +00:00)",
                                                                       "ErrorID: 1 (6/13/2015 10:00:00 AM +00:00)")));
            }
        }
Ejemplo n.º 2
0
        public void SetUtc_SetsUtcTime()
        {
            var born = 11.March(1977).InUtc();

            using (TimeReseter.SetUtc(born))
            {
                Assert.That(Time.UtcNow, Is.EqualTo(born));
            }
        }
Ejemplo n.º 3
0
        public void SetUtc_SetsBackUtcTimeWhenDisposed()
        {
            var born    = 11.March(1977).InUtc();
            var reseter = TimeReseter.SetUtc(born);

            reseter.Dispose();
            DateTimeOffset timeNow = Time.UtcNow, dtNow = DateTimeOffset.UtcNow;

            Assert.That(timeNow - dtNow, Is.LessThan(Time.OneSecond));
        }
Ejemplo n.º 4
0
        public void Create_Archives_Delete_Expired()
        {
            string baseDirectory = Guid.NewGuid().ToString("N");

            try
            {
                var logger = Substitute.For <ILogger>();

                var subject = new FileBasedArchiveService(new InMemoryRuntimeSettings()
                                                          .Set(FileBasedArchiveService.BaseDirectoryKey, baseDirectory), logger);

                using (TimeReseter.SetUtc(new DateTimeOffset(2015, 9, 22, 12, 0, 0, TimeSpan.Zero)))
                {
                    subject.ArchiveText("Name", "Content", options => options
                                        .Named("Archive Name 1")
                                        .ExpiresAfterDays(1));

                    ArchiveCreated archive2 = subject.ArchiveText("Name", "Content", options => options
                                                                  .Named("Archive Name 2")
                                                                  .ExpiresOn(new DateTimeOffset(2015, 10, 1, 12, 0, 0, TimeSpan.Zero)));

                    Archive[] archives = subject.GetAll();
                    Assert.That(archives.Length, Is.EqualTo(2));

                    using (TimeReseter.SetUtc(new DateTimeOffset(2015, 9, 24, 0, 0, 0, TimeSpan.Zero)))
                    {
                        int expired = subject.DeleteExpired();

                        Assert.That(expired, Is.EqualTo(1));

                        archives = subject.GetAll();

                        Assert.That(archives.Length, Is.EqualTo(1));
                        Assert.That(archives[0].Id, Is.EqualTo(archive2.Id));
                        Assert.That(archives[0].Name, Is.EqualTo("Archive Name 2"));

                        // zip + meta file
                        Assert.That(Directory.EnumerateFiles(baseDirectory).Count(), Is.EqualTo(2));
                    }
                }
            }
            finally
            {
                Directory.Delete(baseDirectory, true);
            }
        }
Ejemplo n.º 5
0
        public void SetUtc_NonUtcTime_Exception()
        {
            DateTimeOffset nonUtc = 11.March(1977).In(2.Hours());

            Assert.That(() => TimeReseter.SetUtc(nonUtc), Throws.InstanceOf <InvalidTimeZoneException>());
        }