public void Should_succeed()
        {
            Glitch.Config.WithApiUrl("http://localhost:1289/v1/errors")
            .WithApiKey("6b36472946f04a32805a35fead592856")
            .WithNotificationsMaxBatchSize(2);
            ErrorQueue.Clear();

            Glitch.Notifications.OnBatchDelivered += Instance_OnBatchDelivered;
            try
            {
                throw new InvalidOperationException("test1");
            }
            catch (Exception ex)
            {
                Glitch.Factory.Error(ex)
                .With("TestKey", "TestValue")
                .WithUser("testUser1")
                .WithLocation("http://test/12234")
                .Send();
            }

            Glitch.Factory.Error(new ArgumentException("test2"))
            .WithUser("testUser2")
            .WithLocation("Controller1#Action2")
            .Send();

            Assert.IsTrue(ErrorDeliveryTask.Wait(TimeSpan.FromMinutes(1)));
            Glitch.Notifications.Stop(TimeSpan.Zero);
            Glitch.Notifications.OnBatchDelivered -= Instance_OnBatchDelivered;
            var info = ErrorDeliveryTask.Result;

            Assert.AreEqual(2, info.ErrorBatch.Errors.Length);
            Assert.IsNull(info.Exception);
            Assert.IsTrue(info.Succeeded);
        }
Ejemplo n.º 2
0
 public void TestInitialize()
 {
     _testErrorSenderWorker = new TestErrorSenderWorker();
     ErrorQueue.Clear();
 }