fix params bugs
This commit is contained in:
@@ -11,9 +11,6 @@ namespace UptimeSharp.Tests
|
||||
public MonitorsTest() : base() { }
|
||||
|
||||
|
||||
public async Task Dispose() { }
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void AddHTTPMonitor()
|
||||
{
|
||||
@@ -91,15 +88,7 @@ namespace UptimeSharp.Tests
|
||||
));
|
||||
|
||||
List<Monitor> items = await client.GetMonitors();
|
||||
Monitor monitor = null;
|
||||
|
||||
items.ForEach(item =>
|
||||
{
|
||||
if (item.Name == "test_6")
|
||||
{
|
||||
monitor = item;
|
||||
}
|
||||
});
|
||||
Monitor monitor = items.SingleOrDefault(item => item.Name == "test_6");
|
||||
|
||||
Assert.NotNull(monitor);
|
||||
|
||||
|
||||
@@ -114,24 +114,24 @@ namespace UptimeSharp.Models
|
||||
|
||||
if ((int)Type != 0)
|
||||
{
|
||||
parameters.Add("monitorType", Type.ToString());
|
||||
parameters.Add("monitorType", ((int)Type).ToString());
|
||||
}
|
||||
|
||||
// special params for port listener
|
||||
if (Type == Type.Port && Subtype != Subtype.Unknown)
|
||||
{
|
||||
parameters.Add("monitorSubType", Subtype.ToString());
|
||||
parameters.Add("monitorSubType", ((int)Subtype).ToString());
|
||||
|
||||
if (Subtype == Subtype.Custom && Port.HasValue)
|
||||
{
|
||||
parameters.Add("monitorPort", Port.ToString());
|
||||
parameters.Add("monitorPort", ((int)Port).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// keyword listener
|
||||
if (Type == Type.Keyword && !String.IsNullOrEmpty(KeywordValue))
|
||||
{
|
||||
parameters.Add("monitorKeywordType", KeywordType.ToString());
|
||||
parameters.Add("monitorKeywordType", ((int)KeywordType).ToString());
|
||||
parameters.Add("monitorKeywordValue", KeywordValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,11 @@ namespace UptimeSharp.Models
|
||||
}
|
||||
|
||||
// convert array to comma-seperated list
|
||||
if (value is IEnumerable && value.GetType().GetElementType() == typeof(string))
|
||||
if (value is Array && (value as Array).Length > 0)
|
||||
{
|
||||
value = String.Join("-", value);
|
||||
}
|
||||
else if (value is IEnumerable && value.GetType().GetElementType() == typeof(string))
|
||||
{
|
||||
value = String.Join("-", ((IEnumerable)value).Cast<object>().Select(x => x.ToString()).ToArray());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user