示例#1
0
        public void Tree_Lazy_Child_ResolvesOnlyOnce()
        {
            var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.MultiLevelContainer));

            var validator = new EventValidator(client, new[]
            {
                //Get Object
                UnitRequest.Objects("filter_objid=1001"),

                //Get Probe
                UnitRequest.Probes("filter_objid=1001&filter_parentid=0"),

                //Probe -> Devices/Groups
                UnitRequest.Devices("filter_parentid=1001"),
                UnitRequest.Groups("filter_parentid=1001"),

                //Probe -> Device -> Sensors
                UnitRequest.Sensors("filter_parentid=3001")
            });

            validator.MoveNext(2);
            var tree = client.GetTreeLazy(1001);

            validator.MoveNext(2);
            var child      = tree.Children[0];
            var childAgain = tree.Children[0];

            validator.MoveNext();
            var grandChild      = child.Children[0];
            var grandChildAgain = child.Children[0];
        }
示例#2
0
        public void Tree_Lazy_Id_OneAPIRequest()
        {
            var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.ContainerWithGrandChild));

            var validator = new EventValidator(client, new[]
            {
                UnitRequest.Objects("filter_objid=1001"),
                UnitRequest.Probes("filter_objid=1001&filter_parentid=0")
            });

            validator.MoveNext(2);

            var tree = client.GetTreeLazy(1001);
        }
示例#3
0
        public async Task PrtgClient_ParsesInvalidXml_RetainsDirtyAsync()
        {
            var xml = "<property><value>\01</value></property>";

            var client = BaseTest.Initialize_Client(new BasicResponse(xml.ToString()));

            var validator = new EventValidator <string>(new[]
            {
                //First - retry a dirty response
                "https://prtg.example.com/api/table.xml?content=objects&columns=objid,name,tags,type,active,basetype&count=*&username=username&passhash=12345678",
                "XmlSerializer encountered exception ''.', hexadecimal value 0x00, is an invalid character. Line 1, position 18.' while processing request. Retrying request and flagging engine as dirty.",
                "https://prtg.example.com/api/table.xml?content=objects&columns=objid,name,tags,type,active,basetype&count=*&username=username&passhash=12345678",

                //Second - engine should be already marked as dirty
                "https://prtg.example.com/api/table.xml?content=objects&columns=objid,name,tags,type,active,basetype&count=*&username=username&passhash=12345678"
            });

            client.LogVerbose += (s, e) =>
            {
                var message = e.Message;

                if (message.StartsWith("Synchronously") || message.StartsWith("Asynchronously"))
                {
                    message = Regex.Replace(e.Message, "(.+ request )(.+)", "$2");
                }

                Assert.AreEqual(validator.Get(message), message);
            };

            validator.MoveNext(3);
            var result = await client.ObjectEngine.GetObjectAsync <DummyElementRoot>(new PrtgObjectParameters());

            validator.MoveNext();
            result = await client.ObjectEngine.GetObjectAsync <DummyElementRoot>(new PrtgObjectParameters());

            Assert.IsTrue(validator.Finished, "Did not process all requests");
        }