private static SyntheticsJsonRoot GetNamedMonitors(GetMonitors monitorRetriver, string monitorsNamesCollection)
        {
            var monitorNames = monitorsNamesCollection.Split(',');

            var monitorsArray = new Monitor[monitorNames.Length];

            for (var counter = 0; counter < monitorNames.Length; counter++)
            {
                var monitor = monitorRetriver.GetMonitorByName(monitorNames[counter]);
                if (monitor != null)
                {
                    monitorsArray[counter] = monitor;
                }
                else
                {
                    //we need a monitor name from setup to identify an error
                    monitorsArray[counter] = new Monitor
                    {
                        Name = monitorNames[counter]
                    };
                }
            }

            var monitorsCollection = new SyntheticsJsonRoot
            {
                Count    = monitorNames.Length,
                Monitors = monitorsArray
            };

            return(monitorsCollection);
        }
示例#2
0
        protected void SetUp()
        {
            var appSettingKey = ConfigurationManager.AppSettings.Get("ApiKey");

            this.apiKey             = !string.IsNullOrWhiteSpace(appSettingKey) ? appSettingKey : string.Empty;
            monitorRetriver         = new GetMonitors(this.apiKey);
            this.monitorsCollection = this.monitorRetriver.GetAllMonitors();
        }
示例#3
0
        private void ChangeMonitorsStatus(SyntheticsJsonRoot monitorsCollections, bool targetStatus)
        {
            var monitorUpdater = new UpdateMonitor(apiKey);

            foreach (var monitor in monitorsCollections.Monitors)
            {
                monitorUpdater.Execute(monitor, targetStatus);
            }
        }
示例#4
0
        private static bool CheckAllMonitorsStatus(SyntheticsJsonRoot monitorsCollection)
        {
            var returnValue = true;

            foreach (var monitor in monitorsCollection.Monitors)
            {
                returnValue = monitor.IsEnabled;
            }

            return(returnValue);
        }