コード例 #1
0
        public void HealthCheckForFileServer()
        {
            var destinationPath = "C://1.txt";

            var server = new FileServer(destinationPath);

            var eMail = new EMail("*****@*****.**");

            var notifications = new List <INotification> {
                eMail
            };

            var healthCheckerInstance = new HealthChecker.HealthChecker(server, notifications);

            if (!healthCheckerInstance.Server.HealthCheck())
            {
                healthCheckerInstance.Notifications.ForEach(x =>
                {
                    var result = x.SendAlarm();
                    Assert.Equal(eMail.SuccessTextResult, result);
                });
            }
        }
コード例 #2
0
        public void HealthCheckForWebServer()
        {
            var url = "www.google.com";

            var server = new WebServer(url);

            var telephone = new Telephone("02133252194");

            var notifications = new List <INotification> {
                telephone
            };

            var healthCheckerInstance = new HealthChecker.HealthChecker(server, notifications);

            if (!healthCheckerInstance.Server.HealthCheck())
            {
                healthCheckerInstance.Notifications.ForEach(x =>
                {
                    var result = x.SendAlarm();
                    Assert.Equal(telephone.SuccessTextResult, result);
                });
            }
        }
コード例 #3
0
        public void HealthCheckForDbServer()
        {
            var connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password = myPassword;";
            var dBQuery          = "SELECT COUNT(*) FROM sys.dm_os_performance_counters";

            var server = new DBServer(connectionString, dBQuery);

            var sms = new SMS("09936386808");

            var notifications = new List <INotification> {
                sms
            };

            var healthCheckerInstance = new HealthChecker.HealthChecker(server, notifications);

            if (!healthCheckerInstance.Server.HealthCheck())
            {
                healthCheckerInstance.Notifications.ForEach(x =>
                {
                    var result = x.SendAlarm();
                    Assert.Equal(sms.SuccessTextResult, result);
                });
            }
        }