mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add GetCommitDatesAsyncShould tests
This commit is contained in:
parent
de6cc43884
commit
86f5ac1a87
1 changed files with 32 additions and 6 deletions
|
|
@ -9,17 +9,43 @@ namespace FilterLists.Services.Tests.GitHub
|
|||
public class GetCommitDatesAsyncShould
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnCorrectCommitDatesForValidGitHubRawUrl()
|
||||
public async Task ReturnCorrectFirstAndLastCommitDatesForValidGitHubRawUrl()
|
||||
{
|
||||
const string rawFileUrl = "https://raw.githubusercontent.com/collinbarrett/FilterLists/master/LICENSE";
|
||||
var expectedCommitDates = new CommitDates
|
||||
const string url = "https://raw.githubusercontent.com/collinbarrett/FilterLists/master/LICENSE";
|
||||
var expectedDates = new CommitDates
|
||||
{
|
||||
First = DateTime.Parse("2016-12-10T20:28:16.0000000"),
|
||||
Last = DateTime.Parse("2018-01-24T00:08:21.0000000")
|
||||
};
|
||||
var actualCommitDates = await new GitHubService().GetCommitDatesAsync(rawFileUrl);
|
||||
Assert.Equal(expectedCommitDates.First, actualCommitDates.First);
|
||||
Assert.Equal(expectedCommitDates.Last, actualCommitDates.Last);
|
||||
var actualDates = await new GitHubService().GetCommitDatesAsync(url);
|
||||
Assert.Equal(expectedDates.First, actualDates.First);
|
||||
Assert.Equal(expectedDates.Last, actualDates.Last);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnNullForInvalidGitHubRawUrl()
|
||||
{
|
||||
const string url = "https://github.com/collinbarrett/FilterLists/blob/master/.gitattributes";
|
||||
var actualDates = await new GitHubService().GetCommitDatesAsync(url);
|
||||
Assert.Null(actualDates);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnNullForValidGitHubRawUrlToNonexistentFile()
|
||||
{
|
||||
const string url = "https://github.com/collinbarrett/FilterLists/blob/master/doesnotexist";
|
||||
var actualDates = await new GitHubService().GetCommitDatesAsync(url);
|
||||
Assert.Null(actualDates);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnSameFirstAndLastCommitDatesForValidGitHubRawUrlWithOnlyOneCommit()
|
||||
{
|
||||
const string url = "https://raw.githubusercontent.com/collinbarrett/FilterLists/master/.gitattributes";
|
||||
var expectedDate = DateTime.Parse("2017-04-08T00:05:26.0000000");
|
||||
var actualDates = await new GitHubService().GetCommitDatesAsync(url);
|
||||
Assert.Equal(expectedDate, actualDates.First);
|
||||
Assert.Equal(expectedDate, actualDates.Last);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue