Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Upgrade Moq to 4.5.21 and use Shouldly
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Sep 2, 2016
1 parent 397e332 commit 71edcd3
Show file tree
Hide file tree
Showing 22 changed files with 1,002 additions and 995 deletions.
12 changes: 10 additions & 2 deletions CakeMail.RestClient.UnitTests/CakeMail.RestClient.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.5.21.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.5.21\lib\net45\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand All @@ -48,6 +52,10 @@
<HintPath>..\packages\RestSharp.105.2.3\lib\net452\RestSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Shouldly, Version=2.8.2.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
<HintPath>..\packages\Shouldly.2.8.2\lib\net451\Shouldly.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions CakeMail.RestClient.UnitTests/CakeMailRestClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using RestSharp;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;

namespace CakeMail.RestClient.UnitTests
Expand Down Expand Up @@ -36,10 +36,10 @@ public void RestClient_constructor()
var proxy = apiClient.Proxy;

// Assert
Assert.AreEqual("CakeMail .NET REST Client", userAgentParts[0]);
Assert.AreEqual(new Uri($"https://{mockHost}"), baseUrl);
Assert.AreEqual(mockTimeout, timeout);
Assert.AreEqual(new Uri(string.Format("http://{0}:{1}", mockProxyHost, mockProxyPort)), ((WebProxy)proxy).Address);
userAgentParts[0].ShouldBe("CakeMail .NET REST Client");
baseUrl.ShouldBe(new Uri($"https://{mockHost}"));
timeout.ShouldBe(mockTimeout);
((WebProxy)proxy).Address.ShouldBe(new Uri(string.Format("http://{0}:{1}", mockProxyHost, mockProxyPort)));
}

[TestMethod]
Expand All @@ -66,10 +66,10 @@ public void RestClient_constructor_with_IRestClient()
var proxy = apiClient.Proxy;

// Assert
Assert.AreEqual(mockUserAgent, userAgent);
Assert.AreEqual(mockBaseUrl, baseUrl);
Assert.AreEqual(mockTimeout, timeout);
Assert.AreEqual(new Uri(string.Format("http://{0}:{1}", mockProxyHost, mockProxyPort)), ((WebProxy)proxy).Address);
userAgent.ShouldBe(mockUserAgent);
baseUrl.ShouldBe(mockBaseUrl);
timeout.ShouldBe(mockTimeout);
((WebProxy)proxy).Address.ShouldBe(new Uri(string.Format("http://{0}:{1}", mockProxyHost, mockProxyPort)));
}

[TestMethod]
Expand Down
93 changes: 47 additions & 46 deletions CakeMail.RestClient.UnitTests/Campaigns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using RestSharp;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;

namespace CakeMail.RestClient.UnitTests
{
Expand Down Expand Up @@ -32,7 +33,7 @@ public async Task CreateCampaign_with_minimal_parameters()
var result = await apiClient.Campaigns.CreateAsync(USER_KEY, campaignName);

// Assert
Assert.IsNotNull(result);
result.ShouldNotBeNull();
}

[TestMethod]
Expand All @@ -54,7 +55,7 @@ public async Task CreateCampaign_with_clientid()
var result = await apiClient.Campaigns.CreateAsync(USER_KEY, campaignName, CLIENT_ID);

// Assert
Assert.IsNotNull(result);
result.ShouldNotBeNull();
}

[TestMethod]
Expand All @@ -74,7 +75,7 @@ public async Task DeleteCampaign_with_minimal_parameters()
var result = await apiClient.Campaigns.DeleteAsync(USER_KEY, campaignId);

// Assert
Assert.IsTrue(result);
result.ShouldBeTrue();
}

[TestMethod]
Expand All @@ -95,7 +96,7 @@ public async Task DeleteCampaign_with_clientid()
var result = await apiClient.Campaigns.DeleteAsync(USER_KEY, campaignId, CLIENT_ID);

// Assert
Assert.IsTrue(result);
result.ShouldBeTrue();
}

[TestMethod]
Expand All @@ -115,8 +116,8 @@ public async Task GetCampaign_with_minimal_parameters()
var result = await apiClient.Campaigns.GetAsync(USER_KEY, campaignId, null);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(campaignId, result.Id);
result.ShouldNotBeNull();
result.Id.ShouldBe(campaignId);
}

[TestMethod]
Expand All @@ -137,8 +138,8 @@ public async Task GetCampaign_with_clientid()
var result = await apiClient.Campaigns.GetAsync(USER_KEY, campaignId, CLIENT_ID);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(campaignId, result.Id);
result.ShouldNotBeNull();
result.Id.ShouldBe(campaignId);
}

[TestMethod]
Expand All @@ -159,10 +160,10 @@ public async Task GetCampaigns_with_minimal_parameters()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -185,10 +186,10 @@ public async Task GetCampaign_with_status()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, status: status);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -211,10 +212,10 @@ public async Task GetCampaign_with_name()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, name: name);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -237,10 +238,10 @@ public async Task GetCampaign_with_sortby()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, sortBy: sortBy);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -263,10 +264,10 @@ public async Task GetCampaign_with_sortdirection()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, sortDirection: sortDirection);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -289,10 +290,10 @@ public async Task GetCampaign_with_limit()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, limit: limit);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -315,10 +316,10 @@ public async Task GetCampaign_with_offset()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, offset: offset);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -340,10 +341,10 @@ public async Task GetCampaigns_with_clientid()
var result = await apiClient.Campaigns.GetListAsync(USER_KEY, clientId: CLIENT_ID);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(2, result.Count());
Assert.AreEqual(123, result.ToArray()[0].Id);
Assert.AreEqual(456, result.ToArray()[1].Id);
result.ShouldNotBeNull();
result.Count().ShouldBe(2);
result.ToArray()[0].Id.ShouldBe(123);
result.ToArray()[1].Id.ShouldBe(456);
}

[TestMethod]
Expand All @@ -362,7 +363,7 @@ public async Task GetCampaignCount_with_minimal_parameters()
var result = await apiClient.Campaigns.GetCountAsync(USER_KEY);

// Assert
Assert.AreEqual(2, result);
result.ShouldBe(2);
}

[TestMethod]
Expand All @@ -383,7 +384,7 @@ public async Task GetCampaignCount_with_status()
var result = await apiClient.Campaigns.GetCountAsync(USER_KEY, status: status);

// Assert
Assert.AreEqual(2, result);
result.ShouldBe(2);
}

[TestMethod]
Expand All @@ -404,7 +405,7 @@ public async Task GetCampaignCount_with_name()
var result = await apiClient.Campaigns.GetCountAsync(USER_KEY, name: name);

// Assert
Assert.AreEqual(2, result);
result.ShouldBe(2);
}

[TestMethod]
Expand All @@ -424,7 +425,7 @@ public async Task GetCampaignCount_with_clientid()
var result = await apiClient.Campaigns.GetCountAsync(USER_KEY, clientId: CLIENT_ID);

// Assert
Assert.AreEqual(2, result);
result.ShouldBe(2);
}

[TestMethod]
Expand All @@ -446,7 +447,7 @@ public async Task UpdateCampaign_with_minimal_parameters()
var result = await apiClient.Campaigns.UpdateAsync(USER_KEY, campaignId, name);

// Assert
Assert.IsTrue(result);
result.ShouldBeTrue();
}

[TestMethod]
Expand All @@ -469,7 +470,7 @@ public async Task UpdateCampaign_with_clientid()
var result = await apiClient.Campaigns.UpdateAsync(USER_KEY, campaignId, name, CLIENT_ID);

// Assert
Assert.IsTrue(result);
result.ShouldBeTrue();
}
}
}
Loading

0 comments on commit 71edcd3

Please sign in to comment.