2022-06-30 01:46:41 +02:00
|
|
|
|
using Bit.Icons.Services;
|
2021-10-28 20:30:41 +02:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
namespace Bit.Icons.Test.Services;
|
|
|
|
|
|
2023-08-08 21:29:40 +02:00
|
|
|
|
public class IconFetchingServiceTests : ServiceTestBase<IconFetchingService>
|
2021-10-28 20:30:41 +02:00
|
|
|
|
{
|
2024-06-03 15:58:53 +02:00
|
|
|
|
[Theory(Skip = "Run ad-hoc")]
|
2023-08-08 21:29:40 +02:00
|
|
|
|
[InlineData("www.twitter.com")] // https site
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[InlineData("www.google.com")] // https site
|
|
|
|
|
[InlineData("neverssl.com")] // http site
|
2023-08-08 21:29:40 +02:00
|
|
|
|
[InlineData("neopets.com")] // uses favicon.ico
|
|
|
|
|
[InlineData("hopin.com")] // uses svg+xml format
|
2024-06-03 15:58:53 +02:00
|
|
|
|
[InlineData("tdameritrade.com")]
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[InlineData("icloud.com")]
|
|
|
|
|
public async Task GetIconAsync_Success(string domain)
|
2022-08-29 20:53:16 +02:00
|
|
|
|
{
|
2023-08-08 21:29:40 +02:00
|
|
|
|
var sut = BuildSut();
|
2022-08-29 22:06:55 +02:00
|
|
|
|
var result = await sut.GetIconAsync(domain);
|
2022-08-29 20:53:16 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
Assert.NotNull(result);
|
|
|
|
|
}
|
2022-08-29 20:53:16 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("1.1.1.1")]
|
|
|
|
|
[InlineData("")]
|
|
|
|
|
[InlineData("localhost")]
|
|
|
|
|
public async Task GetIconAsync_ReturnsNull(string domain)
|
|
|
|
|
{
|
2023-08-08 21:29:40 +02:00
|
|
|
|
var sut = BuildSut();
|
2022-08-29 22:06:55 +02:00
|
|
|
|
var result = await sut.GetIconAsync(domain);
|
|
|
|
|
|
|
|
|
|
Assert.Null(result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 21:29:40 +02:00
|
|
|
|
private IconFetchingService BuildSut() =>
|
|
|
|
|
GetService<IconFetchingService>();
|
2021-10-28 20:30:41 +02:00
|
|
|
|
}
|