Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves / Migrates project to .NET standard #23

Merged
merged 10 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,15 @@ cd dnsimple-csharp

#### 2. Install dependencies

- Linux
- .NET Core SDK

Please follow the instructions on the [Mono Project Page](https://www.mono-project.com/download/stable/#download-lin)

- macOS

Install .NET [mono](https://www.mono-project.com/) either by [dowloading mono](https://www.mono-project.com/download/stable/#download-mac)
directly or by using [Homebrew](https://brew.sh)

```
brew install mono
```

Make sure your dotnet installation is working.

```shell
mono --version
```

- Windows
From https://dotnet.microsoft.com/download/dotnet-core/

Please follow the instructions on the [Microsoft Docs Website](https://docs.microsoft.com/en-us/dotnet/framework/install)
You can either use to install the .NET Core SDK
- Installers
- Binaries
- [Scripts](https://dotnet.microsoft.com/download/dotnet-core/scripts)
- Install [Visual Studio](https://visualstudio.microsoft.com/)

#### 3. Build and test

Expand All @@ -46,7 +33,7 @@ To run the test suite:
```shell
./build.sh
```

- Windows
```shell
PS> .\build.ps1
Expand Down
9 changes: 3 additions & 6 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0

var target = Argument("target", "Default");

var buildDir = Directory("./src/dnsimple/bin");
Expand Down Expand Up @@ -28,9 +26,8 @@ Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
NUnit3("./src/**/bin/**/*_test.dll", new NUnit3Settings {
NoResults = true
});

DotNetCoreTest();
});

Task("Package")
Expand All @@ -48,5 +45,5 @@ Task("Package")

Task("Default")
.IsDependentOn("Test");

RunTarget(target);
2 changes: 1 addition & 1 deletion src/dnsimple-test/FixtureLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private IEnumerable<string> GetLines(bool removeEmptyLines = false)
private string LoadFixture()
{
var path = Path.Combine(Environment.CurrentDirectory,
$"src/dnsimple-test/fixtures/{Version}/api/" + Fixture);
$"fixtures/{Version}/api/" + Fixture);

return File.ReadAllText(path);
}
Expand Down
5 changes: 3 additions & 2 deletions src/dnsimple-test/MockDnsimpleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using dnsimple.Services;
using Newtonsoft.Json.Linq;
using RestSharp;
using RestSharp.Extensions;
using ICredentials = dnsimple.ICredentials;

namespace dnsimple_test
Expand Down Expand Up @@ -79,7 +80,7 @@ public void SetUserAgent(string customUserAgent)

public string RequestSentTo()
{
return ((MockHttpService) Http).RequestUrlSent;
return ((MockHttpService) Http).RequestUrlSent.UrlDecode();
}

public Method HttpMethodUsed()
Expand Down Expand Up @@ -124,7 +125,7 @@ public override IRestResponse Execute(IRestRequest request)
PayloadSent = (string) request.Parameters.Find(x =>
x.ContentType.Equals("application/json")).Value;
}
catch (Exception e)
catch (Exception)
{
// ignored
}
Expand Down
35 changes: 0 additions & 35 deletions src/dnsimple-test/Properties/AssemblyInfo.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/dnsimple-test/Services/CertificatesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void ListCertificates(long accountId, string domainName,

[Test]
[TestCase(1010, "ruby.codes",
"https://api.sandbox.dnsimple.com/v2/1010/domains/ruby.codes/certificates?sort=id:asc%2ccommon_name:desc%2cexpiration:asc&per_page=42&page=7")]
"https://api.sandbox.dnsimple.com/v2/1010/domains/ruby.codes/certificates?sort=id:asc,common_name:desc,expiration:asc&per_page=42&page=7")]
public void ListCertificatesWithOptions(long accountId,
string domainName, string expectedUrl)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dnsimple-test/Services/ContactsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void ListContacts(long accountId, string expectedUrl)

[Test]
[TestCase(1010,
"https://api.sandbox.dnsimple.com/v2/1010/contacts?sort=id:asc%2clabel:desc%2cemail:asc&per_page=42&page=7")]
"https://api.sandbox.dnsimple.com/v2/1010/contacts?sort=id:asc,label:desc,email:asc&per_page=42&page=7")]
public void ListContactsWitSorting(long accountId, string expectedUrl)
{
var client = new MockDnsimpleClient(ListContactsFixture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public void ListDelegationSignerRecords(long accountId,

[Test]
[TestCase(1010, "100",
"https://api.sandbox.dnsimple.com/v2/1010/domains/100/ds_records?sort=id:asc%2ccreated_at:desc&per_page=5&page=3")]
"https://api.sandbox.dnsimple.com/v2/1010/domains/100/ds_records?sort=id:asc,created_at:desc&per_page=5&page=3")]
[TestCase(1010, "example.com",
"https://api.sandbox.dnsimple.com/v2/1010/domains/example.com/ds_records?sort=id:asc%2ccreated_at:desc&per_page=5&page=3")]
"https://api.sandbox.dnsimple.com/v2/1010/domains/example.com/ds_records?sort=id:asc,created_at:desc&per_page=5&page=3")]
public void ListDelegationSignerRecordsWithOptions(long accountId,
string domainIdentifier, string expectedUrl)
{
Expand Down Expand Up @@ -254,4 +254,4 @@ public void DeleteDelegationSignerRecord(long accountId,
});
}
}
}
}
24 changes: 12 additions & 12 deletions src/dnsimple-test/Services/ServicesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ServicesTest
private MockResponse _response;
private const string ListServicesFixture = "listServices/success.http";
private const string GetServiceFixture = "getService/success.http";

private DateTime CreatedAt { get; } = DateTime.ParseExact(
"2014-02-14T19:15:19Z", "yyyy-MM-ddTHH:mm:ssZ",
CultureInfo.CurrentCulture);
Expand All @@ -29,14 +29,14 @@ public void Initialize()
var loader = new FixtureLoader("v2", ListServicesFixture);
_response = new MockResponse(loader);
}

[Test]
public void ListServicesResponse()
{
var services = new PaginatedResponse<Service>(_response).Data;
var service = services.First();
var serviceSetting = services.Last().Settings.First();

Assert.Multiple(() =>
{
Assert.AreEqual(1, service.Id);
Expand All @@ -49,7 +49,7 @@ public void ListServicesResponse()
Assert.AreEqual(CreatedAt, service.CreatedAt);
Assert.AreEqual(UpdatedAt, service.UpdatedAt);
Assert.IsEmpty(service.Settings);

Assert.AreEqual(1,services.Last().Settings.Count);
Assert.AreEqual("username", serviceSetting.Name);
Assert.AreEqual("Service 2 Account Username", serviceSetting.Label);
Expand All @@ -59,14 +59,14 @@ public void ListServicesResponse()
Assert.IsFalse(serviceSetting.Password);
});
}

[Test]
[TestCase("https://api.sandbox.dnsimple.com/v2/services")]
public void ListServices(string expectedUrl)
{
var client = new MockDnsimpleClient(ListServicesFixture);
var services = client.Services.ListServices().Data;

Assert.Multiple(() =>
{
Assert.AreEqual(2, services.Count);
Expand All @@ -75,7 +75,7 @@ public void ListServices(string expectedUrl)
}

[Test]
[TestCase("https://api.sandbox.dnsimple.com/v2/services?sort=id:asc%2csid:desc&per_page=42&page=7")]
[TestCase("https://api.sandbox.dnsimple.com/v2/services?sort=id:asc,sid:desc&per_page=42&page=7")]
public void ListServicesWithSorting(string expectedUrl)
{
var client = new MockDnsimpleClient(ListServicesFixture);
Expand All @@ -86,12 +86,12 @@ public void ListServicesWithSorting(string expectedUrl)
PerPage = 42,
Page = 7
}

}.SortById(Order.asc)
.SortBySid(Order.desc);

client.Services.ListServices(options);

Assert.AreEqual(expectedUrl, client.RequestSentTo());
}

Expand All @@ -102,7 +102,7 @@ public void GetService(string serviceId, string expectedUrl)
var client = new MockDnsimpleClient(GetServiceFixture);
var service = client.Services.GetService(serviceId).Data;
var setting = service.Settings.First();

Assert.Multiple(() =>
{
Assert.AreEqual(1, service.Id);
Expand All @@ -114,7 +114,7 @@ public void GetService(string serviceId, string expectedUrl)
Assert.IsNull(service.DefaultSubdomain);
Assert.AreEqual(CreatedAt, service.CreatedAt);
Assert.AreEqual(UpdatedAt, service.UpdatedAt);

Assert.AreEqual("username", setting.Name);
Assert.AreEqual("Service 1 Account Username", setting.Label);
Assert.AreEqual(".service1.com", setting.Append);
Expand All @@ -124,4 +124,4 @@ public void GetService(string serviceId, string expectedUrl)
});
}
}
}
}
18 changes: 9 additions & 9 deletions src/dnsimple-test/Services/TemplateRecordsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TemplateRecordsTest

private const string GetTemplateRecordFixture =
"getTemplateRecord/success.http";

private const string DeleteTemplateRecordFixture =
"deleteTemplateRecord/success.http";

Expand Down Expand Up @@ -84,7 +84,7 @@ public void ListTemplateRecords(long accountId, string template,

[Test]
[TestCase(1010, "268",
"https://api.sandbox.dnsimple.com/v2/1010/templates/268/records?sort=id:asc%2cname:desc%2ccontent:asc%2ctype:desc&per_page=42&page=7")]
"https://api.sandbox.dnsimple.com/v2/1010/templates/268/records?sort=id:asc,name:desc,content:asc,type:desc&per_page=42&page=7")]
public void ListTemplateRecordsSorted(long accountId, string template,
string expectedUrl)
{
Expand Down Expand Up @@ -118,11 +118,11 @@ public void CreateTemplateRecord(long accountId, string template, string expecte
Ttl = 600,
Priority = 10
};

var record =
client.Templates.CreateTemplateRecord(accountId, template,
templateRecord).Data;

Assert.Multiple(() =>
{
Assert.AreEqual(300, record.Id);
Expand All @@ -132,7 +132,7 @@ public void CreateTemplateRecord(long accountId, string template, string expecte
Assert.AreEqual(templateRecord.Content, record.Content);
Assert.AreEqual(templateRecord.Ttl, record.Ttl);
Assert.AreEqual(templateRecord.Priority, record.Priority);

Assert.AreEqual(Method.POST, client.HttpMethodUsed());
Assert.AreEqual(expectedUrl, client.RequestSentTo());
});
Expand All @@ -147,12 +147,12 @@ public void GetTemplateRecord(long accountId, string template, long recordId, st
var record =
client.Templates.GetTemplateRecord(accountId, template,
recordId).Data;

Assert.Multiple(() =>
{
Assert.AreEqual(recordId, record.Id);
Assert.AreEqual(268, record.TemplateId);

Assert.AreEqual(expectedUrl, client.RequestSentTo());
});
}
Expand All @@ -166,12 +166,12 @@ public void DeleteTemplateRecord(long accountId, string template, long recordId,

client.Templates.DeleteTemplateRecord(accountId, template,
recordId);

Assert.Multiple(() =>
{
Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
Assert.AreEqual(expectedUrl, client.RequestSentTo());
});
}
}
}
}
Loading