public void ShouldSerializeProperly() { HTTPService restService = new HTTPService { Type = "TestService", Name = "TestService", Url = "testeurl.com" }; TCPService tcpService = new TCPService { Type = "TestService", Name = "TestService", Host = "testeurl.com", Port = "5555" }; var arcGISHealtChekerGroup = new ArcGISHealthCheckerGroup { Name = "TestProject", HTTPServices = new List<HTTPService> { restService }, TCPServices = new List<TCPService> { tcpService } }; var arcGISHealtCheker = new ArcGISHealthChecker { Groups = new List<ArcGISHealthCheckerGroup> { arcGISHealtChekerGroup } }; var testFile = GetTempTestFileName(); ConfigurationReader.SerializeToXML(arcGISHealtCheker, testFile); File.Exists(testFile).Should().Be.True(); File.Delete(testFile); }
public void TestServiceON() { var tcpService = new TCPService() { Type = "Test", Name = "TestName", Host = "192.213.102.115", Port = "5151" }; ServiceStatus status = checker.CheckTCPService(tcpService); Assert.AreEqual("ON", status.Status); }
public ServiceStatus CheckTCPService(TCPService Service) { var serviceStatus = new ServiceStatus() { Name = Service.Name, Type = Service.Type, }; try { var client = new TcpClient(Service.Host, Convert.ToInt32(Service.Port)); serviceStatus.Status = client.Connected ? "ON" : "OFF"; } catch (Exception) { serviceStatus.Status = "OFF"; } return serviceStatus; }