mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 12:26:18 +00:00
fix timezone offset handling (#1988)
* port tests to use DateTimeOffset * drop the whitespace when emitting DateTimeOffset values * tidy up stale regions
This commit is contained in:
@@ -215,11 +215,11 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchUsersRequest("github");
|
||||
request.Created = DateRange.GreaterThan(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
client.SearchUsers(request);
|
||||
connection.Received().Get<SearchUsersResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/users"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -228,11 +228,11 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchUsersRequest("github");
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
client.SearchUsers(request);
|
||||
connection.Received().Get<SearchUsersResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/users"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -241,11 +241,11 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchUsersRequest("github");
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
client.SearchUsers(request);
|
||||
connection.Received().Get<SearchUsersResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/users"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -254,11 +254,11 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchUsersRequest("github");
|
||||
request.Created = DateRange.LessThan(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.LessThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
client.SearchUsers(request);
|
||||
connection.Received().Get<SearchUsersResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/users"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -267,11 +267,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchUsersRequest("github");
|
||||
request.Created = DateRange.Between(new DateTime(2014, 1, 1), new DateTime(2014, 2, 1));
|
||||
request.Created = DateRange.Between(
|
||||
new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero),
|
||||
new DateTimeOffset(new DateTime(2014, 2, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchUsers(request);
|
||||
|
||||
connection.Received().Get<SearchUsersResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/users"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:2014-01-01..2014-02-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:2014-01-01T00:00:00+00:00..2014-02-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -525,10 +529,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been created after year jan 1 2011
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Created = DateRange.GreaterThan(new DateTime(2011, 1, 1));
|
||||
request.Created = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2011, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>2011-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>2011-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -538,10 +542,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been created after year jan 1 2011
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTime(2011, 1, 1));
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2011, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>=2011-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:>=2011-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -551,10 +555,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been created after year jan 1 2011
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Created = DateRange.LessThan(new DateTime(2011, 1, 1));
|
||||
request.Created = DateRange.LessThan(new DateTimeOffset(new DateTime(2011, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<2011-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<2011-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
|
||||
@@ -565,10 +569,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been created after year jan 1 2011
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTime(2011, 1, 1));
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2011, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<=2011-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<=2011-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -577,10 +581,14 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Created = DateRange.Between(new DateTime(2011, 1, 1), new DateTime(2012, 11, 11));
|
||||
request.Created = DateRange.Between(
|
||||
new DateTimeOffset(new DateTime(2011, 1, 1), TimeSpan.Zero),
|
||||
new DateTimeOffset(new DateTime(2012, 11, 11), TimeSpan.Zero));
|
||||
|
||||
client.SearchRepo(request);
|
||||
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:2011-01-01..2012-11-11"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:2011-01-01T00:00:00+00:00..2012-11-11T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -590,10 +598,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been pushed before year jan 1 2013
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Updated = DateRange.GreaterThan(new DateTime(2013, 1, 1));
|
||||
request.Updated = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2013, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:>2013-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:>2013-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -603,10 +611,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been pushed before year jan 1 2013
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Updated = DateRange.GreaterThanOrEquals(new DateTime(2013, 1, 1));
|
||||
request.Updated = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2013, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:>=2013-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:>=2013-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -616,10 +624,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been pushed before year jan 1 2013
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Updated = DateRange.LessThan(new DateTime(2013, 1, 1));
|
||||
request.Updated = DateRange.LessThan(new DateTimeOffset(new DateTime(2013, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:<2013-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:<2013-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -629,10 +637,10 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
//get repos where the search contains 'github' and has been pushed before year jan 1 2013
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Updated = DateRange.LessThanOrEquals(new DateTime(2013, 1, 1));
|
||||
request.Updated = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2013, 1, 1), TimeSpan.Zero));
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:<=2013-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:<=2013-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -641,10 +649,14 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Updated = DateRange.Between(new DateTime(2012, 4, 30), new DateTime(2012, 7, 4));
|
||||
request.Updated = DateRange.Between(
|
||||
new DateTimeOffset(new DateTime(2012, 4, 30), TimeSpan.Zero),
|
||||
new DateTimeOffset(new DateTime(2012, 7, 4), TimeSpan.Zero));
|
||||
|
||||
client.SearchRepo(request);
|
||||
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:2012-04-30..2012-07-04"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+pushed:2012-04-30T00:00:00+00:00..2012-07-04T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -983,21 +995,19 @@ namespace Octokit.Tests.Clients
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:CSharp"));
|
||||
}
|
||||
|
||||
#region The following tests do not support the time component or timezone and will be removed in a future release
|
||||
|
||||
[Fact]
|
||||
public void TestingTheCreatedQualifier_GreaterThan()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.GreaterThan(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1006,13 +1016,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1021,13 +1031,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.LessThan(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.LessThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1036,13 +1046,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Created = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1051,13 +1061,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.Between(new DateTime(2014, 1, 1), new DateTime(2014, 2, 2));
|
||||
request.Created = DateRange.Between(
|
||||
new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero),
|
||||
new DateTimeOffset(new DateTime(2014, 2, 2), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:2014-01-01..2014-02-02"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:2014-01-01T00:00:00+00:00..2014-02-02T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1066,13 +1078,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.GreaterThan(new DateTime(2014, 1, 1));
|
||||
request.Merged = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1081,13 +1093,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Merged = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1096,13 +1108,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.LessThan(new DateTime(2014, 1, 1));
|
||||
request.Merged = DateRange.LessThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1111,13 +1123,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Merged = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1126,13 +1138,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.Between(new DateTime(2014, 1, 1), new DateTime(2014, 2, 2));
|
||||
request.Merged = DateRange.Between(
|
||||
new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero),
|
||||
new DateTimeOffset(new DateTime(2014, 2, 2), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:2014-01-01..2014-02-02"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:2014-01-01T00:00:00+00:00..2014-02-02T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1141,13 +1155,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Updated = DateRange.GreaterThan(new DateTime(2014, 1, 1));
|
||||
request.Updated = DateRange.GreaterThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1156,13 +1170,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Updated = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Updated = DateRange.GreaterThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1171,13 +1185,13 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Updated = DateRange.LessThan(new DateTime(2014, 1, 1));
|
||||
request.Updated = DateRange.LessThan(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1186,19 +1200,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Updated = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1));
|
||||
request.Updated = DateRange.LessThanOrEquals(new DateTimeOffset(new DateTime(2014, 1, 1), TimeSpan.Zero));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<=2014-01-01"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<=2014-01-01T00:00:00+00:00"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region The following tests include support the time component and timezone
|
||||
|
||||
[Fact]
|
||||
public void TestingTheCreatedQualifier_GreaterThanDateTime()
|
||||
{
|
||||
@@ -1211,7 +1221,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1226,7 +1236,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:>=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1240,7 +1250,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1255,7 +1265,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:<=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1264,13 +1274,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Created = DateRange.Between(new DateTimeOffset(2014, 1, 1, 2, 4, 6, new TimeSpan(10, 0, 0)), new DateTimeOffset(2014, 2, 2, 2, 4, 6, new TimeSpan(10, 0, 0)));
|
||||
request.Created = DateRange.Between(
|
||||
new DateTimeOffset(2014, 1, 1, 2, 4, 6, new TimeSpan(10, 0, 0)),
|
||||
new DateTimeOffset(2014, 2, 2, 2, 4, 6, new TimeSpan(10, 0, 0)));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:2014-01-01T02:04:06 +10:00..2014-02-02T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:2014-01-01T02:04:06+10:00..2014-02-02T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1285,7 +1297,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1300,7 +1312,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1315,7 +1327,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1330,7 +1342,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1339,13 +1351,15 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Merged = DateRange.Between(new DateTimeOffset(2014, 1, 1, 2, 4, 6, new TimeSpan(10, 0, 0)), new DateTimeOffset(2014, 2, 2, 2, 4, 6, new TimeSpan(10, 0, 0)));
|
||||
request.Merged = DateRange.Between(
|
||||
new DateTimeOffset(2014, 1, 1, 2, 4, 6, new TimeSpan(10, 0, 0)),
|
||||
new DateTimeOffset(2014, 2, 2, 2, 4, 6, new TimeSpan(10, 0, 0)));
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:2014-01-01T02:04:06 +10:00..2014-02-02T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:2014-01-01T02:04:06+10:00..2014-02-02T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1360,7 +1374,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1375,7 +1389,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:>=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1390,7 +1404,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1405,12 +1419,9 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received().Get<SearchIssuesResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<=2014-01-01T02:04:06 +10:00"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+updated:<=2014-01-01T02:04:06+10:00"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestingTheCommentsQualifier_GreaterThan()
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SearchIssuesRequestTests
|
||||
Assert.False(request.MergedQualifiers().Any(x => x.Contains(property.Key)));
|
||||
|
||||
// Set the parameter
|
||||
property.Value(request, DateRange.GreaterThan(DateTime.Today.AddDays(-7)));
|
||||
property.Value(request, DateRange.GreaterThan(new DateTimeOffset(DateTime.Today.AddDays(-7))));
|
||||
|
||||
// Ensure the specified parameter now exists
|
||||
Assert.True(request.MergedQualifiers().Count(x => x.Contains(property.Key)) == 1);
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class DateRange
|
||||
{
|
||||
public const string DateTimePattern = "yyyy-MM-dd'T'HH:mm:ss zzz";
|
||||
public const string DateTimePattern = "yyyy-MM-dd'T'HH:mm:sszzz";
|
||||
public const string DatePattern = "yyyy-MM-dd";
|
||||
|
||||
private readonly string query = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user