Skip to content

Commit

Permalink
Fixed an issue wherein DynamicSensorParameters prohibit assigning a n…
Browse files Browse the repository at this point in the history
…on-sensor target enumerable value to a custom parameter
  • Loading branch information
lordmilko committed Apr 23, 2018
1 parent 9468565 commit 45388da
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
6 changes: 2 additions & 4 deletions PrtgAPI.Tests.IntegrationTests/DataTests/LogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ public void Data_Log_GetLogs_SpecifiesStartDate()
{
var count = 6000;

var logs = client.GetLogs(null, DateTime.Now.AddDays(-1), count: count);

AssertEx.AreEqual(count, logs.Count, "Did not retrieve expected number of logs");
var logs = client.GetLogs(null, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-1).AddHours(-6), count);

var first = logs.First();
var last = logs.Last();

AssertEx.AreEqual(DateTime.Now.AddDays(-1).Date, first.DateTime.Date, "Start date was incorrect");
AssertEx.IsTrue(last.DateTime.Date < DateTime.Now.AddDays(-2), "Logs didn't appear to go back far enough");
AssertEx.IsTrue(last.DateTime < DateTime.Now.AddDays(-1).AddHours(-5), "Logs didn't appear to go back far enough");
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ public void DynamicSensorParameters_Indexer_Throws_SetMultiple_ForNonTarget()
{
var parameters = client.GetDynamicSensorParameters(1001, "exexml");

Assert.IsTrue(parameters["name"] != null);
parameters["exeparams"] = new[] {1, 2};

AssertEx.Throws<ArgumentException>(() => parameters["name"] = new[] {1, 2}, "Collections (excluding Sensor Targets) cannot be assigned to dynamic sensor parameters");
var arr = ((int[]) parameters["exeparams"]);

Assert.AreEqual(1, arr[0]);
Assert.AreEqual(2, arr[1]);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,12 @@ Describe "New-SensorParameters" {
$params.exefile[1].ToString() | Should Be "testScript.bat"
}

It "throws setting multiple objects that are not sensor targets" {
It "sets multiple objects that are not sensor targets" {
$params = GetDynamicParams

{ $params.environment = 3,4 } | Should Throw "Collections (excluding Sensor Targets) cannot be assigned to dynamic sensor parameters"
$params.environment = 3,4
$params.environment[0] | Should Be 3
$params.environment[1] | Should Be 4
}

It "locks and unlocks" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ internal override void SetIndex(string name, object value)
}
else
{
if (value is IEnumerable && !(value is string))
throw new ArgumentException("Collections (excluding Sensor Targets) cannot be assigned to dynamic sensor parameters. Please assign a single object whose string representation is valid for this parameter.");

SetOrAddCustom(prop, name, value);
}
}
Expand Down
3 changes: 2 additions & 1 deletion PrtgAPI/PowerShell/Cmdlets/ConnectPrtgServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ namespace PrtgAPI.PowerShell.Cmdlets
/// If -RetryCount is greater than 0, PrtgAPI will send a warning to the pipeline indicating a failure has occurred,
/// as well as the number of retries remaining before PrtgAPI gives up. Each request invocation uses a separate retry count.</para>
///
/// <para>If a protocol is not specified, PrtgAPI will connect with HTTPS. If your PRTG Server is HTTP only, this will cause an exception.
/// <para type="description">If a protocol is not specified, PrtgAPI will connect with HTTPS. If your PRTG Server is HTTP only, this will cause an exception.
/// For HTTP only servers, prefix your URL with http://</para>
///
/// <para type="description">When Connect-PrtgServer is run from outside of a script or the PowerShell ISE, PrtgAPI will
/// display PowerShell progress when piping between PrtgAPI cmdlets or when piping from variables containing PrtgAPI objects.
/// This default setting can be overridden by specifying a value to the -Progress parameter, or by using the Enable-PrtgProgress
Expand Down
6 changes: 3 additions & 3 deletions PrtgAPI/PowerShell/Cmdlets/ObjectManipulation/PauseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace PrtgAPI.PowerShell.Cmdlets
/// <para type="description">The Pause-Object cmdlet disables monitoring of an object in PRTG. When an object is paused, all children
/// of the object are paused as well. Child objects can be independently paused and unpaused while their parent is paused,
/// however their states will not modify as long as their parent is overriding them.</para>
///
/// <para type="description">When pausing an object, you must specify how long to pause the object for. While in a paused state
/// PRTG will not attempt to execute any sensor objects covered by the paused object.</para>
/// <para>Objects that have not been paused forever will be automatically unpaused when their pause duration expires. For information
/// on how to unpause an object manually, see Resume-Object.</para>
/// PRTG will not attempt to execute any sensor objects covered by the paused object. Objects that have not been paused forever
/// will be automatically unpaused when their pause duration expires. For information on how to unpause an object manually, see Resume-Object.</para>
///
/// <para type="description">By default, Pause-Object will operate in Batch Mode. In Batch Mode, Pause-Object
/// will not execute a request for each individual object, but will rather store each item in a queue to pause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace PrtgAPI.PowerShell.Cmdlets
/// refresh according to their Scanning Interval. Refresh-Object allows you to bypass this interval and request
/// the sensor update immediately. If Refresh-Object is applied to a Device, Group or Probe, all sensors under
/// that object will be refreshed.</para>
/// <para>Sensor Factory sensors do not support being manually refreshed.</para>
///
/// <para type="description">Sensor Factory sensors do not support being manually refreshed.</para>
///
/// <para type="description">By default, Refresh-Object will operate in Batch Mode. In Batch Mode, Refresh-Object
/// will not execute a request for each individual object, but will rather store each item in a queue to refresh
Expand Down
2 changes: 1 addition & 1 deletion PrtgAPI/PowerShell/Resources/PrtgAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PrtgAPI.dll'

# Version number of this module.
ModuleVersion = '0.8.3'
ModuleVersion = '0.8.4'

# ID used to uniquely identify this module
GUID = '81d4380f-31ff-42c7-9d64-1678dc5cd978'
Expand Down
4 changes: 2 additions & 2 deletions PrtgAPI/Properties/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//0
//8
//3
//4
//0
//
// This code was generated by a tool. Any changes made manually will be lost
Expand All @@ -9,4 +9,4 @@

using System.Reflection;

[assembly: AssemblyFileVersion("0.8.3.0")]
[assembly: AssemblyFileVersion("0.8.4.0")]

0 comments on commit 45388da

Please sign in to comment.