Exemplo n.º 1
0
        public void TriggerSnapshot()
        {
            using var service = new OnDemandSnapshotTrigger();

            // closure is never null because Assert.Raises<T> will execute
            // 'attach' and 'detach' before and after 'testCode' respectively, before returning
            // ReSharper disable AccessToDisposedClosure
            Assert.Raises <EventArgs>(handler => service.SnapshotTriggered += handler,
                                      handler => service.SnapshotTriggered -= handler,
                                      () => { TestAction <AcceptedResult>(c => c.TriggerSnapshot()); });
            // ReSharper restore AccessToDisposedClosure
        }
 public IActionResult TriggerSnapshot()
 {
     try
     {
         OnDemandSnapshotTrigger.TriggerOnDemandSnapshot();
         return(Accepted());
     }
     catch (Exception e)
     {
         Logger.LogWarning(e, "error while triggering On-Demand snapshot");
         return(StatusCode(HttpStatusCode.InternalServerError));
     }
 }