remove empty parameters

This commit is contained in:
2014-02-02 11:23:27 +01:00
parent 2f9bda6c76
commit 29ffceb920
4 changed files with 34 additions and 7 deletions
+8 -6
View File
@@ -1,8 +1,7 @@
using Xunit; using System.Collections.Generic;
using System.Collections.Generic;
using UptimeSharp.Models;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using UptimeSharp.Models;
using Xunit;
namespace UptimeSharp.Tests namespace UptimeSharp.Tests
{ {
@@ -59,11 +58,14 @@ namespace UptimeSharp.Tests
List<Alert> alerts = await client.GetAlerts(); List<Alert> alerts = await client.GetAlerts();
Assert.InRange(alerts.ToArray().Length, 2, 100); Assert.InRange(alerts.Count, 2, 100);
List<Alert> specificAlerts = await client.GetAlerts(new string[] { alerts[0].ID, alerts[1].ID }); List<Alert> specificAlerts = await client.GetAlerts(new string[] { alerts[0].ID, alerts[1].ID });
Assert.Equal(2, specificAlerts.ToArray().Length); Assert.Equal(2, specificAlerts.Count);
await client.DeleteAlert(alerts[0]);
await client.DeleteAlert(alerts[1]);
} }
+4
View File
@@ -71,6 +71,10 @@ namespace UptimeSharp.Models
/// </summary> /// </summary>
public enum AlertType public enum AlertType
{ {
/// <summary>
/// Unknown
/// </summary>
Unknown,
/// <summary> /// <summary>
/// SMS /// SMS
/// </summary> /// </summary>
@@ -0,0 +1,21 @@
using Newtonsoft.Json;
namespace UptimeSharp.Models
{
/// <summary>
/// Alert Response
/// </summary>
[JsonObject]
internal class AddAlertResponse : Response
{
/// <summary>
/// Gets or sets the item dictionary.
/// The list is 2 layers deep, so this one is necessary :-/
/// </summary>
/// <value>
/// The item dictionary.
/// </value>
[JsonProperty("alertcontact")]
public Alert Alert { get; set; }
}
}
+1 -1
View File
@@ -119,7 +119,7 @@ namespace UptimeSharp
// with this param it can return raw JSON // with this param it can return raw JSON
parameters.Add("noJsonCallback", "1"); parameters.Add("noJsonCallback", "1");
IEnumerable<string> paramEnumerable = parameters.Select(item => Uri.EscapeDataString(item.Key) + "=" + Uri.EscapeDataString(item.Value)); IEnumerable<string> paramEnumerable = parameters.Where(item => !String.IsNullOrEmpty(item.Value)).Select(item => Uri.EscapeDataString(item.Key) + "=" + Uri.EscapeDataString(item.Value));
// content of the request // content of the request
request = new HttpRequestMessage(HttpMethod.Get, method + "?" + String.Join("&", paramEnumerable)); request = new HttpRequestMessage(HttpMethod.Get, method + "?" + String.Join("&", paramEnumerable));