swap NUnit with xUnit.NET!

This commit is contained in:
2013-08-26 01:07:19 +02:00
parent 6f29cadd26
commit e4f6fe2928
6 changed files with 47 additions and 50 deletions
+2 -2
View File
@@ -82,7 +82,7 @@ List<Monitor> items = _client.GetMonitors(
monitorIDs: new int[]{ 12891, 98711 },
customUptimeRatio: new float[] { 7, 30, 45 },
showLog: true,
showAlerts = true
showAlerts: true
);
```
@@ -115,7 +115,7 @@ bool AddMonitor(
)
```
Example - Watch the a SMTP Server:
Example - Watch an SMTP Server:
```csharp
bool isSuccess = _client.AddMonitor(
+27 -29
View File
@@ -1,11 +1,11 @@
using NUnit.Framework;
using Xunit;
using System.Collections.Generic;
using UptimeSharp.Models;
using System;
namespace UptimeSharp.Tests
{
[TestFixture]
public class AlertsTest
public class AlertsTest : IDisposable
{
UptimeClient client;
@@ -14,76 +14,74 @@ namespace UptimeSharp.Tests
string APIKey = "u97240-a24c634b3b84f1af602628e8";
[SetUp]
public void Setup()
// setup
public AlertsTest()
{
client = new UptimeClient(APIKey);
}
[TearDown]
public void Teardown()
// teardown
public void Dispose()
{
List<Alert> alerts = client.GetAlerts();
alerts.ForEach(alert => client.DeleteAlert(alert));
}
[Test]
[ExpectedException(typeof(APIException))]
[Fact]
public void AddInvalidAlertWithTypeSms()
{
client.AddAlert(Models.AlertType.SMS, "+436601289172");
Assert.Throws<APIException>(() =>
{
client.AddAlert(Models.AlertType.SMS, "+436601289172");
});
}
[Test]
[ExpectedException(typeof(APIException))]
[Fact]
public void AddInvalidAlertWithTypeTwitter()
{
client.AddAlert(Models.AlertType.Twitter, "artistandsocial");
Assert.Throws<APIException>(() =>
{
client.AddAlert(Models.AlertType.Twitter, "artistandsocial");
});
}
[Test]
[Fact]
public void AddAndRemoveAlerts()
{
string email = "example@ceecore.com";
Assert.IsTrue(client.AddAlert(AlertType.Email, email), "Response should be true for adding a new alert");
Assert.True(client.AddAlert(AlertType.Email, email));
Alert origin = GetOriginAlert(email);
Assert.AreEqual(email, origin.Value, "Retrieved alert should have the value (example@ceecore.com) which was submitted");
Assert.AreEqual(AlertType.Email, origin.Type, "Retrieved alert should have the type (email) which was submitted");
Assert.Equal(email, origin.Value);
Assert.Equal(AlertType.Email, origin.Type);
client.DeleteAlert(origin);
origin = GetOriginAlert(email);
Assert.IsNull(origin, "Alert should have been deleted");
Assert.Null(origin);
}
[Test]
[Fact]
public void AddAndRetrieveSpecificAlerts()
{
Assert.IsTrue(
client.AddAlert(AlertType.Email, "example1@ceecore.com"),
"Response should be true for adding a new alert (email 1)"
);
Assert.IsTrue(
client.AddAlert(AlertType.Boxcar, "example@ceecore.com"),
"Response should be true for adding a new alert (bocar 4)"
);
Assert.True(client.AddAlert(AlertType.Email, "example1@ceecore.com"));
Assert.True(client.AddAlert(AlertType.Boxcar, "example@ceecore.com"));
List<Alert> alerts = client.GetAlerts();
Assert.GreaterOrEqual(alerts.ToArray().Length, 2, "Alerts length should be at least 2", alerts);
Assert.InRange(alerts.ToArray().Length, 2, 100);
List<Alert> specificAlerts = client.GetAlerts(new int[] { alerts[0].ID, alerts[1].ID });
Assert.AreEqual(2, specificAlerts.ToArray().Length, "Specific alerts length should be 2", specificAlerts);
Assert.Equal(2, specificAlerts.ToArray().Length);
}
+6 -7
View File
@@ -1,10 +1,9 @@
using NUnit.Framework;
using Xunit;
using System.Collections.Generic;
using UptimeSharp.Models;
namespace UptimeSharp.Tests
{
[TestFixture]
public class ClientTest
{
UptimeClient client;
@@ -14,19 +13,19 @@ namespace UptimeSharp.Tests
string APIKey = "u97240-a24c634b3b84f1af602628e8";
[SetUp]
public void Setup()
// setup
public ClientTest()
{
client = new UptimeClient(APIKey);
}
[Test]
[Fact]
public void Initialize()
{
Assert.IsNull(client.LastRequestData, "LastRequestData should be null on init");
Assert.Null(client.LastRequestData);
Assert.AreEqual(APIKey, client.ApiKey, "API Key should be correctly assigned");
Assert.Equal(APIKey, client.ApiKey);
}
}
}
+8 -8
View File
@@ -1,11 +1,11 @@
using NUnit.Framework;
using Xunit;
using System;
using System.Collections.Generic;
using UptimeSharp.Models;
namespace UptimeSharp.Tests
{
[TestFixture]
public class MonitorsTest
public class MonitorsTest : IDisposable
{
UptimeClient client;
@@ -14,17 +14,17 @@ namespace UptimeSharp.Tests
string APIKey = "u97240-a24c634b3b84f1af602628e8";
[SetUp]
public void Setup()
// setup
public MonitorsTest()
{
//client = new UptimeClient(APIKey);
}
[TearDown]
public void Teardown()
// teardown
public void Dispose()
{
//List<Alert> alerts = client.RetrieveAlerts();
//List<Alert> alerts = client.GetAlerts();
//alerts.ForEach(alert => client.DeleteAlert(alert));
}
+3 -3
View File
@@ -30,9 +30,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
@@ -48,6 +45,9 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AlertsTest.cs" />
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="RestSharp" version="104.1" targetFramework="net40" />
<package id="ServiceStack.Text" version="3.9.58" targetFramework="net40" />
<package id="xunit" version="1.9.2" targetFramework="net40" />
</packages>