Exemplo n.º 1
0
        public void SystemInfo_Hardware_PropertiesMapCorrectly()
        {
            var name         = "\"Name\"";
            var description  = "\"Description\"";
            var @class       = "\"Class\"";
            var caption      = "\"Caption\"";
            var state        = "\"<img src=\\\"/images/state_.png\\\"> State\"";
            var serialNumber = "\"SerialNumber\"";
            var capacity     = "1234567890123456789";
            var displayName  = "\"DisplayName\"";

            var obj = GetSystemInfoResponse <DeviceHardwareInfo>(
                SystemInfoItem.HardwareItem(name, description, @class, caption,
                                            state, serialNumber, capacity, displayName
                                            )
                );

            AssertAreEqual(name, obj.Name);
            AssertAreEqual(description, obj.Description);
            AssertAreEqual(@class, obj.Class);
            AssertAreEqual(caption, obj.Caption);
            AssertAreEqual("State", obj.State);
            AssertAreEqual(serialNumber, obj.SerialNumber);
            AssertAreEqual(Convert.ToInt64(capacity), obj.Capacity);
            AssertAreEqual(displayName, obj.DisplayName);
        }
        public void SystemInfo_Hardware_PropertiesMapCorrectly()
        {
            var name         = "\"Name\"";
            var description  = "\"Description\"";
            var @class       = "\"Class\"";
            var caption      = "\"Caption\"";
            var state        = "\"<img src=\\\"/images/state_.png\\\"> State\"";
            var serialNumber = "\"SerialNumber\"";
            var capacity     = "1234567890123456789";
            var receiveTime  = "01-02-2003 21:10:13.425";
            var displayName  = "\"DisplayName\"";

            var obj = GetSystemInfoResponse <DeviceHardwareInfo>(
                SystemInfoItem.HardwareItem(name, description, @class, caption,
                                            state, serialNumber, capacity, receiveTime, displayName
                                            )
                );

            AssertAreEqual(name, obj.Name);
            AssertAreEqual(description, obj.Description);
            AssertAreEqual(@class, obj.Class);
            AssertAreEqual(caption, obj.Caption);
            AssertAreEqual("State", obj.State);
            AssertAreEqual(serialNumber, obj.SerialNumber);
            AssertAreEqual(Convert.ToInt64(capacity), obj.Capacity);
            AssertAreEqual(DateTime.ParseExact(receiveTime, "dd-MM-yyyy HH:mm:ss.FFF", CultureInfo.InvariantCulture), obj.LastUpdated);
            AssertAreEqual(displayName, obj.DisplayName);
        }
Exemplo n.º 3
0
 public void SystemInfo_NoPropertiesAreStrings()
 {
     GetSystemInfoResponse <DeviceSystemInfo>(SystemInfoItem.SystemItem("1", "2", "3", "4", "5"));
     GetSystemInfoResponse <DeviceHardwareInfo>(SystemInfoItem.HardwareItem("1", "2", "3", "4", "5", "6", "7", "8"));
     GetSystemInfoResponse <DeviceSoftwareInfo>(SystemInfoItem.SoftwareItem("1", "2", "3", "\"2017-05-23-00-00-00\"", "5", "6"));
     GetSystemInfoResponse <DeviceProcessInfo>(SystemInfoItem.ProcessItem("1", "2", "\"2018-08-31 19:36:26\"", "4"));
     GetSystemInfoResponse <DeviceServiceInfo>(SystemInfoItem.ServiceItem("1", "2", "3", "4", "5"));
     GetSystemInfoResponse <DeviceUserInfo>(SystemInfoItem.UserItem("1", "2", "3"));
 }
Exemplo n.º 4
0
 public void SystemInfo_AllPropertiesAreEmpty()
 {
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceSystemInfo>(SystemInfoItem.SystemItem("\"\"", "\"\"", "\"\"", "\"\"", "\"\""));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceHardwareInfo>(SystemInfoItem.HardwareItem("\"\"", "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", "\"\""));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceSoftwareInfo>(SystemInfoItem.SoftwareItem("\"\"", "\"\"", "\"\"", "\"\"", "\"\"", "\"\""));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceProcessInfo>(SystemInfoItem.ProcessItem("\"0\"", "\"\"", "\"\"", "\"\""));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceServiceInfo>(SystemInfoItem.ServiceItem("\"\"", "\"\"", "\"\"", "\"\"", "\"\"", "\"\""));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceUserInfo>(SystemInfoItem.UserItem("\"\"", "\"\"", "\"\""));
 }
Exemplo n.º 5
0
 public void SystemInfo_AllPropertiesAreNull()
 {
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceSystemInfo>(SystemInfoItem.SystemItem(null, null, null, null, null));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceHardwareInfo>(SystemInfoItem.HardwareItem(null, null, null, null, null, null, null, null));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceSoftwareInfo>(SystemInfoItem.SoftwareItem(null, null, null, null, null, null));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceProcessInfo>(SystemInfoItem.ProcessItem(null, null, null, null));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceServiceInfo>(SystemInfoItem.ServiceItem(null, null, null, null, null, null));
     AssertAllSystemInfoPropertiesDontHaveValues <DeviceUserInfo>(SystemInfoItem.UserItem(null, null, null));
 }
Exemplo n.º 6
0
 private PrtgClient GetFullSummaryClient()
 {
     return(GetSystemInfoClient(
                SystemInfoItem.SystemItem(), SystemInfoItem.SystemItem(),
                SystemInfoItem.HardwareItem(), SystemInfoItem.HardwareItem(),
                SystemInfoItem.SoftwareItem(), SystemInfoItem.SoftwareItem(),
                SystemInfoItem.ProcessItem(), SystemInfoItem.ProcessItem(),
                SystemInfoItem.ServiceItem(), SystemInfoItem.ServiceItem(),
                SystemInfoItem.UserItem(), SystemInfoItem.UserItem()
                ));
 }
Exemplo n.º 7
0
        public void SystemInfo_AllPropertiesHaveValues()
        {
            AssertAllSystemInfoPropertiesHaveValues <DeviceSystemInfo>(SystemInfoItem.SystemItem(), p =>
            {
                if (p.Name == "Type")
                {
                    return(true);
                }

                return(false);
            });

            AssertAllSystemInfoPropertiesHaveValues <DeviceHardwareInfo>(SystemInfoItem.HardwareItem(serialNumber: "1234", capacity: "100"));
            AssertAllSystemInfoPropertiesHaveValues <DeviceSoftwareInfo>(SystemInfoItem.SoftwareItem());
            AssertAllSystemInfoPropertiesHaveValues <DeviceProcessInfo>(SystemInfoItem.ProcessItem());
            AssertAllSystemInfoPropertiesHaveValues <DeviceServiceInfo>(SystemInfoItem.ServiceItem());
            AssertAllSystemInfoPropertiesHaveValues <DeviceUserInfo>(SystemInfoItem.UserItem());
        }
        private IWebResponse GetTableResponse(string address, string function, bool async)
        {
            var components = UrlUtilities.CrackUrl(address);

            Content?content;

            try
            {
                content = components["content"].DescriptionToEnum <Content>();
            }
            catch
            {
                content = null;
            }

            var count = GetCount(components, content);

            //Hack to make test "forces streaming with a date filter and returns no results" work
            if (content == Content.Logs && count == 0 && components["columns"] == "objid,name")
            {
                count   = 501;
                address = address.Replace("count=1", "count=501");
            }

            if (function == nameof(XmlFunction.HistoricData))
            {
                return(new SensorHistoryResponse(GetItems(i => new SensorHistoryItem(), count)));
            }

            var columns = components["columns"]?.Split(',');

            switch (content)
            {
            case Content.Sensors: return(Sensors(CreateSensor, count, columns, address, async));

            case Content.Devices: return(Devices(CreateDevice, count, columns, address, async));

            case Content.Groups:  return(Groups(CreateGroup, count, columns, address, async));

            case Content.Probes: return(Probes(CreateProbe, count, columns, address, async));

            case Content.Logs:
                if (IsGetTotalLogs(address))
                {
                    return(TotalLogsResponse());
                }

                return(Messages(i => new MessageItem($"WMI Remote Ping{i}"), count));

            case Content.History: return(new ModificationHistoryResponse(new ModificationHistoryItem()));

            case Content.Notifications: return(Notifications(CreateNotification, count));

            case Content.Schedules: return(Schedules(CreateSchedule, count));

            case Content.Channels: return(new ChannelResponse(GetItems(Content.Channels, i => new ChannelItem(), 1)));

            case Content.Objects:
                return(Objects(address, function, components));

            case Content.Triggers:
                return(new NotificationTriggerResponse(
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.ThresholdTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group", offNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.SpeedTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group", offNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.VolumeTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group"),
                           NotificationTriggerItem.ChangeTrigger(onNotificationAction: "300|Email to all members of group PRTG Users Group")
                           ));

            case Content.SysInfo:
                return(new SystemInfoResponse(
                           SystemInfoItem.SystemItem(), SystemInfoItem.HardwareItem(), SystemInfoItem.SoftwareItem(),
                           SystemInfoItem.ProcessItem(), SystemInfoItem.ServiceItem(), SystemInfoItem.UserItem()
                           ));

            default:
                throw new NotImplementedException($"Unknown content '{content}' requested from {nameof(MultiTypeResponse)}");
            }
        }