diff --git a/FakerDotNet.sln.DotSettings b/FakerDotNet.sln.DotSettings index 09f27ed..c2f8165 100644 --- a/FakerDotNet.sln.DotSettings +++ b/FakerDotNet.sln.DotSettings @@ -1,4 +1,5 @@  IP RNG + True True \ No newline at end of file diff --git a/README.md b/README.md index f250dd7..d250111 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ A .NET port of the Ruby [faker](https://github.com/stympy/faker) gem - [Faker.DragonBall](doc/dragon_ball.md) - [Faker.Fake](doc/fake.md) - [Faker.File](doc/file.md) + - [Faker.Fillmurray](doc/fillmurray.md) - [Faker.Food](doc/food.md) - [Faker.GameOfThrones](doc/game_of_thrones.md) - [Faker.Hacker](doc/hacker.md) diff --git a/doc/fillmurray.md b/doc/fillmurray.md new file mode 100644 index 0000000..c26633b --- /dev/null +++ b/doc/fillmurray.md @@ -0,0 +1,9 @@ +# Faker.Fillmurray + +```cs +Faker.Fillmurray.Image() //=> "http://fillmurray.com/300/300" + +Faker.Fillmurray.Image(true) //=> "http://fillmurray.com/g/300/300" + +Faker.Fillmurray.Image(false, 200, 400) //=> "http://fillmurray.com/200/400" +``` diff --git a/src/FakerDotNet/Faker.cs b/src/FakerDotNet/Faker.cs index 3248fec..2635e50 100644 --- a/src/FakerDotNet/Faker.cs +++ b/src/FakerDotNet/Faker.cs @@ -23,6 +23,7 @@ public static class Faker public static IDragonBallFaker DragonBall { get; } = Container.DragonBall; public static IFakeFaker Fake { get; } = Container.Fake; public static IFileFaker File { get; } = Container.File; + public static IFillmurrayFaker Fillmurray { get; } = Container.Fillmurray; public static IFoodFaker Food { get; } = Container.Food; public static IFriendsFaker Friends { get; } = Container.Friends; public static IGameOfThronesFaker GameOfThrones { get; } = Container.GameOfThrones; diff --git a/src/FakerDotNet/FakerContainer.cs b/src/FakerDotNet/FakerContainer.cs index 4dd34e7..20c68f0 100644 --- a/src/FakerDotNet/FakerContainer.cs +++ b/src/FakerDotNet/FakerContainer.cs @@ -21,6 +21,7 @@ internal interface IFakerContainer IDragonBallFaker DragonBall { get; } IFakeFaker Fake { get; } IFileFaker File { get; } + IFillmurrayFaker Fillmurray { get; } IFoodFaker Food { get; } IFriendsFaker Friends { get; } IGameOfThronesFaker GameOfThrones { get; } @@ -69,6 +70,7 @@ public FakerContainer() DragonBall = new DragonBallFaker(this); Fake = new FakeFaker(this); File = new FileFaker(this); + Fillmurray = new FillmurrayFaker(); Food = new FoodFaker(this); Friends = new FriendsFaker(this); GameOfThrones = new GameOfThronesFaker(this); @@ -113,6 +115,7 @@ public FakerContainer() public IDragonBallFaker DragonBall { get; } public IFakeFaker Fake { get; } public IFileFaker File { get; } + public IFillmurrayFaker Fillmurray { get; } public IFoodFaker Food { get; } public IFriendsFaker Friends { get; } public IGameOfThronesFaker GameOfThrones { get; } diff --git a/src/FakerDotNet/Fakers/FillmurrayFaker.cs b/src/FakerDotNet/Fakers/FillmurrayFaker.cs new file mode 100644 index 0000000..7bb1cc8 --- /dev/null +++ b/src/FakerDotNet/Fakers/FillmurrayFaker.cs @@ -0,0 +1,18 @@ +namespace FakerDotNet.Fakers +{ + public interface IFillmurrayFaker + { + string Image(bool grayscale = false, int width = 200, int height = 200); + } + + internal class FillmurrayFaker : IFillmurrayFaker + { + public string Image(bool grayscale = false, int width = 200, int height = 200) + { + return grayscale + ? $"https://fillmurray.com/g/{width}/{height}" + : $"https://fillmurray.com/{width}/{height}"; + } + } +} + diff --git a/tests/FakerDotNet.Tests/FakerContainerTests.cs b/tests/FakerDotNet.Tests/FakerContainerTests.cs index 101b71a..ec94c22 100644 --- a/tests/FakerDotNet.Tests/FakerContainerTests.cs +++ b/tests/FakerDotNet.Tests/FakerContainerTests.cs @@ -117,6 +117,12 @@ public void File_returns_IFileFaker() Assert.IsInstanceOf(_fakerContainer.File); } + [Test] + public void Fillmurray_returns_IFillmurrayFaker() + { + Assert.IsInstanceOf(_fakerContainer.Fillmurray); + } + [Test] public void Food_returns_IFoodFaker() { diff --git a/tests/FakerDotNet.Tests/FakerTests.cs b/tests/FakerDotNet.Tests/FakerTests.cs index 6fab331..36ef08a 100644 --- a/tests/FakerDotNet.Tests/FakerTests.cs +++ b/tests/FakerDotNet.Tests/FakerTests.cs @@ -109,6 +109,12 @@ public void File_returns_IFileFaker() Assert.IsInstanceOf(Faker.File); } + [Test] + public void Fillmurray_returns_IFillmurrayFaker() + { + Assert.IsInstanceOf(Faker.Fillmurray); + } + [Test] public void Food_returns_IFoodFaker() { diff --git a/tests/FakerDotNet.Tests/Fakers/FillmurrayFakerTests.cs b/tests/FakerDotNet.Tests/Fakers/FillmurrayFakerTests.cs new file mode 100644 index 0000000..e3a6e9a --- /dev/null +++ b/tests/FakerDotNet.Tests/Fakers/FillmurrayFakerTests.cs @@ -0,0 +1,51 @@ +using FakeItEasy; +using FakerDotNet.Fakers; +using NUnit.Framework; + +namespace FakerDotNet.Tests.Fakers +{ + [TestFixture] + [Parallelizable] + public class FillmurrayFakerTests + { + [SetUp] + public void SetUp() + { + _fillmurrayFaker = new FillmurrayFaker(); + } + + private IFillmurrayFaker _fillmurrayFaker; + + [Test] + public void Image_returns_an_image_url() + { + Assert.AreEqual( + "https://fillmurray.com/200/200", + _fillmurrayFaker.Image()); + } + + [Test] + public void Image_returns_an_image_url_for_a_grayscale_image_when_specified() + { + Assert.AreEqual( + "https://fillmurray.com/g/200/200", + _fillmurrayFaker.Image(true)); + } + + [Test] + public void Image_returns_an_image_url_with_the_specified_width() + { + Assert.AreEqual( + "https://fillmurray.com/300/200", + _fillmurrayFaker.Image(false, 300)); + } + + [Test] + public void Image_returns_an_image_url_with_the_specified_height() + { + Assert.AreEqual( + "https://fillmurray.com/200/400", + _fillmurrayFaker.Image(false, 200, 400)); + } + } +}