public void Setup() { _provider = TestUtility.InitDI(); _notifier = Substitute.For <AggregateNotificationService>(new List <INotificationService>(), null); _service = new StateService(_provider, _notifier); using (var scope = _provider.CreateScope()) using (var dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>()) { dbContext.Endpoints.AddRange(_ep1, _ep2, _ep3); dbContext.SaveChanges(); } _service.AddEndpointCheckResult(_ep2.Id, new EndpointCheckResult { Start = DateTimeOffset.UtcNow, Stop = DateTimeOffset.UtcNow, Success = true }, true); _service.AddEndpointCheckResult(_ep3.Id, new EndpointCheckResult { Start = DateTimeOffset.UtcNow, Stop = DateTimeOffset.UtcNow, Success = false, Error = new Exception("ERROR") }, true); _notifier.ClearReceivedCalls(); }
public void InProgressUpdateShouldNotChangeReportedState() { AssertStateEquality(true, null, _service.GetStatus(_ep2.Id)); var result = new EndpointCheckResult { Start = DateTimeOffset.UtcNow, Stop = DateTimeOffset.UtcNow, Success = false, Error = new Exception("ERR") }; _service.AddEndpointCheckResult(_ep2.Id, result, false); Assert.IsTrue(_service.GetStatus(_ep2.Id).IsInProgress); AssertStateEquality(true, null, _service.GetStatus(_ep2.Id)); AssertResultNotification(_ep2.Id, result); AssertNoUpNotifications(); AssertNoDownNotifications(); }