Skip to content

Commit

Permalink
Remove LoremPixel image service (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnz0r authored Jul 19, 2024
1 parent 3a76b00 commit 070a9dc
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 300 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,6 @@ In the examples above, all three alternative styles of using **Bogus** produce t
* `PicsumUrl` - Get an image from the https://picsum.photos service.
* `PlaceholderUrl` - Get an image from https://placeholder.com service.
* `LoremFlickrUrl` - Get an image from https://loremflickr.com service.
* `LoremPixelUrl` - Creates an image URL with http://lorempixel.com. Note: This service is slow. Consider using PicsumUrl() as a faster alternative.
* `Abstract` - Gets an abstract looking image.
* `Animals` - Gets an image of an animal.
* `Business` - Gets a business looking image.
* `Cats` - Gets a picture of a cat.
* `City` - Gets a city looking image.
* `Food` - Gets an image of food.
* `Nightlife` - Gets an image with city looking nightlife.
* `Fashion` - Gets an image in the fashion category.
* `People` - Gets an image of humans.
* `Nature` - Gets an image of nature.
* `Sports` - Gets an image related to sports.
* `Technics` - Get a technology related image.
* `Transport` - Get a transportation related image.
* **`Internet`**
* `Avatar` - Generates a legit Internet URL avatar from twitter accounts.
* `Email` - Generates an email address.
Expand Down
23 changes: 1 addition & 22 deletions Source/Bogus.Tests/DataSetTests/ImageTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.IO;
using System.Net;
using Bogus.DataSets;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
using static Bogus.DataSets.LoremPixelCategory;

namespace Bogus.Tests.DataSetTests;

Expand All @@ -20,25 +18,6 @@ public ImageTest(ITestOutputHelper console)

private readonly Images image;

[Fact(Skip = "Explicit")]
public void DownloadAllTest()
{
var wc = new WebClient();
wc.DownloadFile(image.LoremPixelUrl(Abstract), "abstract.jpg");
wc.DownloadFile(image.LoremPixelUrl(Animals), "animals.jpg");
wc.DownloadFile(image.LoremPixelUrl(Business), "business.jpg");
wc.DownloadFile(image.LoremPixelUrl(Cats), "cats.jpg");
wc.DownloadFile(image.LoremPixelUrl(City), "city.jpg");
wc.DownloadFile(image.LoremPixelUrl(Food), "food.jpg");
wc.DownloadFile(image.LoremPixelUrl(Nightlife), "nightlife.jpg");
wc.DownloadFile(image.LoremPixelUrl(Fashion), "fashion.jpg");
wc.DownloadFile(image.LoremPixelUrl(People), "people.jpg");
wc.DownloadFile(image.LoremPixelUrl(Nature), "nature.jpg");
wc.DownloadFile(image.LoremPixelUrl(Sports), "sports.jpg");
wc.DownloadFile(image.LoremPixelUrl(Technics), "technics.jpg");
wc.DownloadFile(image.LoremPixelUrl(Transport), "transport.jpg");
}

[Fact]
public void svg_data_url()
{
Expand Down Expand Up @@ -70,7 +49,7 @@ public void svg_data_url()
[Fact]
public void url_generated_should_have_https()
{
image.LoremPixelUrl(Sports, https: true).Should().StartWith("https://");
image.PicsumUrl().Should().StartWith("https://");
}

[Fact]
Expand Down
17 changes: 0 additions & 17 deletions Source/Bogus.Tests/GitHubIssues/PullRequest113.cs

This file was deleted.

202 changes: 0 additions & 202 deletions Source/Bogus/DataSets/Images.LoremPixel.cs

This file was deleted.

45 changes: 0 additions & 45 deletions Source/Bogus/DataSets/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,49 +182,4 @@ public string LoremFlickrUrl(

return Url + sb;
}

/// <summary>
/// Creates an image URL with http://lorempixel.com. Note: This service is slow. Consider using PicsumUrl() as a faster alternative.
/// </summary>
public string LoremPixelUrl(string category = LoremPixelCategory.Random, int width = 640, int height = 480, bool randomize = false, bool https = false)
{
if( category == LoremPixelCategory.Random )
{
var categories = new[]
{
LoremPixelCategory.Abstract,
LoremPixelCategory.Animals,
LoremPixelCategory.Business,
LoremPixelCategory.Cats,
LoremPixelCategory.City,
LoremPixelCategory.Food,
LoremPixelCategory.Nightlife,
LoremPixelCategory.Fashion,
LoremPixelCategory.People,
LoremPixelCategory.Nature,
LoremPixelCategory.Sports,
LoremPixelCategory.Technics,
LoremPixelCategory.Transport
};

category = this.Random.ArrayElement(categories);
}

var proto = "http://";
if( https )
{
proto = "https://";
}
var url = $"{proto}lorempixel.com/{width}/{height}";
if( !string.IsNullOrWhiteSpace(category) )
{
url += $"/{category}";
if( randomize )
{
url += $"/{this.Random.Number(1, 10)}";
}
}

return url;
}
}

0 comments on commit 070a9dc

Please sign in to comment.