示例#1
0
        private void ValidateUrl(string url, IParameters parameters)
        {
            url += "&priority_=3&inherittriggers_=1&intervalgroup=1&interval_=60%7C60+seconds&errorintervalsdown_=1&sensortype=snmplibrary";

            var actual = PrtgRequestMessageTests.CreateUrl(parameters);

            Assert.AreEqual(url, actual);
        }
示例#2
0
        public void ProbeParameters_SearchFilter_ParentId_Equals_ArrayWith_0()
        {
            var parameters = new ProbeParameters(new SearchFilter(Property.ParentId, new[] { 0 }));

            var url = PrtgRequestMessageTests.CreateUrl(parameters, false);

            Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), url);
        }
示例#3
0
        public void RawSensorParameters_WithoutPSObjectUtilities_ObjectArray()
        {
            TestHelpers.WithPSObjectUtilities(() =>
            {
                var parameters = new RawSensorParameters("first", "second");

                var arr = new[] { 1, 2 };

                parameters["third"] = arr;
                Assert.AreEqual(arr, parameters["third"]);

                Assert.IsInstanceOfType(parameters.Parameters.First(p => p.Name == "third").Value, typeof(SimpleParameterContainerValue));

                var url = PrtgRequestMessageTests.CreateUrl(parameters);

                Assert.AreEqual("name_=first&priority_=3&inherittriggers_=1&intervalgroup=1&interval_=60%7C60+seconds&errorintervalsdown_=1&third=1&third=2&sensortype=second", url);
            }, new DefaultPSObjectUtilities());
        }
        public void DynamicSensorParameters_WithoutPSObjectUtilities_ObjectArray()
        {
            TestHelpers.WithPSObjectUtilities(() =>
            {
                var parameters = client.GetDynamicSensorParameters(1001, "exexml");

                var arr = new[] { 1, 2 };

                parameters["mutexname"] = arr;
                Assert.AreEqual(arr, parameters["mutexname"]);

                Assert.IsInstanceOfType(((List <CustomParameter>)(parameters.GetParameters()[Parameter.Custom])).First(p => p.Name == "mutexname_").Value, typeof(SimpleParameterContainerValue));

                var url = PrtgRequestMessageTests.CreateUrl(parameters);

                Assert.IsTrue(url.Contains("mutexname_=1&mutexname_=2"));
            }, new DefaultPSObjectUtilities());
        }
        public void DynamicSensorParameters_Indexer_SetTarget_ForTarget()
        {
            var parameters = client.GetDynamicSensorParameters(1001, "exexml");

            Assert.IsTrue(parameters.Targets.ContainsKey(exefile));
            Assert.AreEqual(2, parameters.Targets[exefile].Length, "Did not have expected number of targets");

            var originalTarget = parameters[exefile];
            var newTarget      = parameters.Targets[exefile].Last();

            Assert.AreNotEqual(originalTarget.ToString(), newTarget.ToString(), "Original and new target were the same");

            parameters[exefile] = newTarget;

            Assert.AreEqual(newTarget, parameters[exefile], "New target was not installed correctly");

            var url = PrtgRequestMessageTests.CreateUrl(parameters);

            var builder = new StringBuilder();

            builder.Append("name_=XML+Custom+EXE%2FScript+Sensor&");
            builder.Append("priority_=3&");
            builder.Append("inherittriggers=1&");
            builder.Append("intervalgroup=1&");
            builder.Append("interval_=60%7C60+seconds&");
            builder.Append("errorintervalsdown_=1&");
            builder.Append("tags_=xmlexesensor&");
            builder.Append("exefilelabel=&");
            builder.Append("exeparams_=&");
            builder.Append("environment_=0&");
            builder.Append("usewindowsauthentication_=0&");
            builder.Append("mutexname_=&");
            builder.Append("timeout_=60&");
            builder.Append("writeresult_=0&");
            builder.Append("exefile=testScript.bat%7CtestScript.bat%7C%7C&");
            builder.Append("sensortype=exexml");

            var str = builder.ToString();

            Assert.AreEqual(str, url, "URL was incorrect");
        }