-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#521) Improve FavIcon download facility
- Loading branch information
1 parent
dab54f0
commit 34121e2
Showing
10 changed files
with
120 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Tests/Lanceur.Tests/Functional/FavIconManagerShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using FluentAssertions; | ||
using Lanceur.Core.Services; | ||
using Lanceur.Infra.Managers; | ||
using Lanceur.SharedKernel.Mixins; | ||
using Lanceur.SharedKernel.Web; | ||
using Microsoft.Extensions.Logging; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Lanceur.Tests.Functional; | ||
|
||
public class FavIconManagerShould | ||
{ | ||
[Theory] | ||
[InlineData("http://www.google.com", "http://www.google.com")] | ||
[InlineData("http://www.google.com:4001", "http://www.google.com:4001")] | ||
[InlineData("http://www.google.com:80", "http://www.google.com:80")] | ||
[InlineData("https://www.google.com", "https://www.google.com")] | ||
[InlineData("https://www.google.com:4001", "https://www.google.com:4001")] | ||
[InlineData("https://www.google.com:80", "https://www.google.com:80")] | ||
[InlineData("https://www.google.com/some/index.html", "https://www.google.com")] | ||
[InlineData("https://www.google.com:4001/some/index.html", "https://www.google.com:4001")] | ||
[InlineData("https://www.google.com:80/some/index.html", "https://www.google.com:80")] | ||
public async Task RetrieveExpectedUrl(string url, string asExpected) | ||
{ | ||
// ARRANGE | ||
var searchService = Substitute.For<IPackagedAppSearchService>(); | ||
var favIconDownloader = Substitute.For<IFavIconDownloader>(); | ||
var logger = Substitute.For<ILoggerFactory>(); | ||
var repository = Path.GetTempPath(); | ||
|
||
// ACT | ||
var manager = new FavIconManager(searchService, favIconDownloader, logger, repository); | ||
await manager.RetrieveFaviconAsync(url); | ||
|
||
// ASSERT | ||
await favIconDownloader.Received() | ||
.CheckExistsAsync(new(asExpected)); | ||
|
||
} | ||
|
||
[Theory] | ||
[InlineData("http://www.google.com", "http://www.google.com/favicon.ico")] | ||
[InlineData("http://www.google.com:4001", "http://www.google.com:4001/favicon.ico")] | ||
[InlineData("http://www.google.com:80", "http://www.google.com:80/favicon.ico")] | ||
[InlineData("https://www.google.com", "https://www.google.com/favicon.ico")] | ||
[InlineData("https://www.google.com:4001", "https://www.google.com:4001/favicon.ico")] | ||
[InlineData("https://www.google.com:80", "https://www.google.com:80/favicon.ico")] | ||
public void CreateFaviconUri(string url, string expected) | ||
{ | ||
var thisUri = new Uri(expected); | ||
new Uri(url).GetFavicons() | ||
.Should().Contain(thisUri); | ||
} | ||
} |