update tests; alert.ID is a string now, cause the main alert has a preceding zero
This commit is contained in:
@@ -24,8 +24,14 @@ namespace UptimeSharp.Tests
|
||||
// teardown
|
||||
public void Dispose()
|
||||
{
|
||||
List<Alert> alerts = client.GetAlerts();
|
||||
alerts.ForEach(alert => client.DeleteAlert(alert));
|
||||
client.GetAlerts().ForEach(alert =>
|
||||
{
|
||||
try
|
||||
{
|
||||
client.DeleteAlert(alert);
|
||||
}
|
||||
catch(UptimeSharpException e){}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +79,13 @@ namespace UptimeSharp.Tests
|
||||
public void AddAndRetrieveSpecificAlerts()
|
||||
{
|
||||
Assert.True(client.AddAlert(AlertType.Email, "example1@ceecore.com"));
|
||||
Assert.True(client.AddAlert(AlertType.Boxcar, "example@ceecore.com"));
|
||||
Assert.True(client.AddAlert(AlertType.Boxcar, "example2@ceecore.com"));
|
||||
|
||||
List<Alert> alerts = client.GetAlerts();
|
||||
|
||||
Assert.InRange(alerts.ToArray().Length, 2, 100);
|
||||
|
||||
List<Alert> specificAlerts = client.GetAlerts(new int[] { alerts[0].ID, alerts[1].ID });
|
||||
List<Alert> specificAlerts = client.GetAlerts(new string[] { alerts[0].ID, alerts[1].ID });
|
||||
|
||||
Assert.Equal(2, specificAlerts.ToArray().Length);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UptimeSharp", "UptimeSharp\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UptimeSharp.Tests", "UptimeSharp.Tests\UptimeSharp.Tests.csproj", "{7AB536B7-1A99-44A7-B5AA-E36E9C7F09F4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{2A5CC10E-451C-4978-A9B7-9F2889A18BCF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,10 +19,6 @@ Global
|
||||
{7AB536B7-1A99-44A7-B5AA-E36E9C7F09F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7AB536B7-1A99-44A7-B5AA-E36E9C7F09F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7AB536B7-1A99-44A7-B5AA-E36E9C7F09F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2A5CC10E-451C-4978-A9B7-9F2889A18BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A5CC10E-451C-4978-A9B7-9F2889A18BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A5CC10E-451C-4978-A9B7-9F2889A18BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A5CC10E-451C-4978-A9B7-9F2889A18BCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace UptimeSharp
|
||||
/// </summary>
|
||||
/// <param name="alertIDs">Retrieve specified alert contacts by supplying IDs for them.</param>
|
||||
/// <returns></returns>
|
||||
public List<Alert> GetAlerts(int[] alertIDs = null)
|
||||
public List<Alert> GetAlerts(string[] alertIDs = null)
|
||||
{
|
||||
Parameter alerts = Parameter("alertcontacts", alertIDs != null ? string.Join("-", alertIDs) : null);
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace UptimeSharp
|
||||
/// </summary>
|
||||
/// <param name="alertID">The alertID.</param>
|
||||
/// <returns></returns>
|
||||
public Alert GetAlert(int alertID)
|
||||
public Alert GetAlert(string alertID)
|
||||
{
|
||||
List<Alert> alerts = GetAlerts(new int[] { alertID });
|
||||
List<Alert> alerts = GetAlerts(new string[] { alertID });
|
||||
|
||||
return alerts.ToArray().Length > 0 ? alerts[0] : null;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace UptimeSharp
|
||||
/// </summary>
|
||||
/// <param name="alertID">The alert ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteAlert(int alertID)
|
||||
public bool DeleteAlert(string alertID)
|
||||
{
|
||||
return Get<DefaultResponse>("deleteAlertContact", Parameter("alertContactID", alertID)).Status;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace UptimeSharp
|
||||
/// <returns></returns>
|
||||
public bool DeleteAlert(Alert alert)
|
||||
{
|
||||
return DeleteAlert((int)alert.ID);
|
||||
return DeleteAlert(alert.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace UptimeSharp
|
||||
/// </returns>
|
||||
public bool AddMonitor(string name, string uri, Type type = Type.HTTP, Subtype subtype = Subtype.Unknown,
|
||||
int? port = null, string keywordValue = null, KeywordType keywordType = KeywordType.Unknown,
|
||||
int[] alerts = null, string HTTPUsername = null, string HTTPPassword = null)
|
||||
string[] alerts = null, string HTTPUsername = null, string HTTPPassword = null)
|
||||
{
|
||||
|
||||
MonitorParameters parameters = new MonitorParameters()
|
||||
@@ -126,11 +126,11 @@ namespace UptimeSharp
|
||||
/// </returns>
|
||||
public bool ModifyMonitor(Monitor monitor)
|
||||
{
|
||||
List<int> alerts = null;
|
||||
List<string> alerts = null;
|
||||
|
||||
if (monitor.Alerts != null)
|
||||
{
|
||||
monitor.Alerts.ForEach(item => alerts.Add((int)item.ID));
|
||||
monitor.Alerts.ForEach(item => alerts.Add(item.ID));
|
||||
}
|
||||
|
||||
MonitorParameters parameters = new MonitorParameters()
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace UptimeSharp.Models
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "id")]
|
||||
public int ID { get; set; }
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alert type.
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace UptimeSharp.Models
|
||||
/// <value>
|
||||
/// The alert contacts.
|
||||
/// </value>
|
||||
public int[] Alerts { get; set; }
|
||||
public string[] Alerts { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user