From e4f6fe2928e61fdbc5855ac61ff705d54b06b7da Mon Sep 17 00:00:00 2001 From: ceee Date: Mon, 26 Aug 2013 01:07:19 +0200 Subject: [PATCH] swap NUnit with xUnit.NET! --- README.md | 4 +- UptimeSharp.Tests/AlertsTest.cs | 56 +++++++++++----------- UptimeSharp.Tests/ClientTest.cs | 13 +++-- UptimeSharp.Tests/MonitorsTest.cs | 16 +++---- UptimeSharp.Tests/UptimeSharp.Tests.csproj | 6 +-- UptimeSharp.Tests/packages.config | 2 +- 6 files changed, 47 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 524e591..3478ad7 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ List 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( diff --git a/UptimeSharp.Tests/AlertsTest.cs b/UptimeSharp.Tests/AlertsTest.cs index 815a2ee..789bdd2 100644 --- a/UptimeSharp.Tests/AlertsTest.cs +++ b/UptimeSharp.Tests/AlertsTest.cs @@ -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 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(() => + { + client.AddAlert(Models.AlertType.SMS, "+436601289172"); + }); } - [Test] - [ExpectedException(typeof(APIException))] + [Fact] public void AddInvalidAlertWithTypeTwitter() { - client.AddAlert(Models.AlertType.Twitter, "artistandsocial"); + Assert.Throws(() => + { + 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 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 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); } diff --git a/UptimeSharp.Tests/ClientTest.cs b/UptimeSharp.Tests/ClientTest.cs index 9dc9c00..2187155 100644 --- a/UptimeSharp.Tests/ClientTest.cs +++ b/UptimeSharp.Tests/ClientTest.cs @@ -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); } } } diff --git a/UptimeSharp.Tests/MonitorsTest.cs b/UptimeSharp.Tests/MonitorsTest.cs index 6051d90..05fc615 100644 --- a/UptimeSharp.Tests/MonitorsTest.cs +++ b/UptimeSharp.Tests/MonitorsTest.cs @@ -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 alerts = client.RetrieveAlerts(); + //List alerts = client.GetAlerts(); //alerts.ForEach(alert => client.DeleteAlert(alert)); } diff --git a/UptimeSharp.Tests/UptimeSharp.Tests.csproj b/UptimeSharp.Tests/UptimeSharp.Tests.csproj index 7b2b8e3..2ea9675 100644 --- a/UptimeSharp.Tests/UptimeSharp.Tests.csproj +++ b/UptimeSharp.Tests/UptimeSharp.Tests.csproj @@ -30,9 +30,6 @@ 4 - - ..\packages\NUnit.2.6.2\lib\nunit.framework.dll - False ..\packages\RestSharp.104.1\lib\net4\RestSharp.dll @@ -48,6 +45,9 @@ + + ..\packages\xunit.1.9.2\lib\net20\xunit.dll + diff --git a/UptimeSharp.Tests/packages.config b/UptimeSharp.Tests/packages.config index f2c2994..f4f7ec5 100644 --- a/UptimeSharp.Tests/packages.config +++ b/UptimeSharp.Tests/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file