public async void ServiceChecker_Throws_Exception_With_Null_ServiceEntry() { var checker = new ServiceChecker(_checkerLogger); await Assert.ThrowsAsync <ArgumentNullException>(async() => await checker.CheckServiceAsync(null, CancellationToken.None)); }
public ServiceCheckerTests() { _messageHandlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); var httpClient = new HttpClient(_messageHandlerMock.Object); _serviceChecker = new ServiceChecker(httpClient); }
public async Task ServiceChecker_Work() { // Arrange var logger = new Mock <ILogger <ServiceChecker> >(); var storeService = new Mock <IStatusLogService>(); var service1 = new Mock <IStatusProvider>(); service1 .Setup(x => x.GetStatusAsync()) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)); var service2 = new Mock <IStatusProvider>(); service2 .Setup(x => x.GetStatusAsync()) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.BadRequest)); var sut = new ServiceChecker(logger.Object, new List <IStatusProvider>() { service1.Object, service2.Object }, storeService.Object); // Act var cts = new CancellationTokenSource(); await sut.StartAsync(cts.Token); await Task.Delay(1000); cts.Cancel(); //Assert service1.Verify(m => m.GetStatusAsync(), Times.Once); service2.Verify(m => m.GetStatusAsync(), Times.Once); storeService.Verify(m => m.AddStatusLog(It.IsAny <StatusLog>()), Times.Exactly(2)); storeService.Verify(m => m.SaveChangesAsync(), Times.Once); }
public override bool IsEnabled() { return(ServiceChecker.IsRunning(name)); }
public ServiceStateMessage(ServiceChecker sender, ServiceControllerStatus?status) : base(sender) { Status = status; }
public override bool IsEnabled() { return(ServiceChecker.IsInstalled(name)); }