From b5c3d782fcb84342ea8437e928982e88b6b426fc Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Thu, 14 Feb 2019 07:36:26 +0000 Subject: [PATCH] Added the MichaelScott faker. (#117) * Added the documentation. * Added the data. * Implemented the MichaelScott faker. * Added the MichaelScott faker to the main faker classes. --- README.md | 1 + doc/michael_scott.md | 5 ++ src/FakerDotNet/Data/MichaelScottData.cs | 51 +++++++++++++++++++ src/FakerDotNet/Faker.cs | 1 + src/FakerDotNet/FakerContainer.cs | 3 ++ src/FakerDotNet/Fakers/MichaelScottFaker.cs | 24 +++++++++ .../FakerDotNet.Tests/FakerContainerTests.cs | 6 +++ tests/FakerDotNet.Tests/FakerTests.cs | 6 +++ .../Fakers/MichaelScottFakerTests.cs | 31 +++++++++++ 9 files changed, 128 insertions(+) create mode 100644 doc/michael_scott.md create mode 100644 src/FakerDotNet/Data/MichaelScottData.cs create mode 100644 src/FakerDotNet/Fakers/MichaelScottFaker.cs create mode 100644 tests/FakerDotNet.Tests/Fakers/MichaelScottFakerTests.cs diff --git a/README.md b/README.md index 5b8cc27..9ffdfa2 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ A .NET port of the Ruby [faker](https://github.com/stympy/faker) gem - [Faker.LoremFlickr](doc/lorem_flickr.md) - [Faker.LoremPixel](doc/lorem_pixel.md) - [Faker.Matz](doc/matz.md) + - [Faker.MichaelScott](doc/michael_scott.md) - [Faker.Music](doc/music.md) - [Faker.Name](doc/name.md) - [Faker.Number](doc/number.md) diff --git a/doc/michael_scott.md b/doc/michael_scott.md new file mode 100644 index 0000000..765132b --- /dev/null +++ b/doc/michael_scott.md @@ -0,0 +1,5 @@ +# Faker.MichaelScott + +```cs +Faker.MichaelScott.Quote() //=> "I am Beyoncé, always." +``` \ No newline at end of file diff --git a/src/FakerDotNet/Data/MichaelScottData.cs b/src/FakerDotNet/Data/MichaelScottData.cs new file mode 100644 index 0000000..2b6be36 --- /dev/null +++ b/src/FakerDotNet/Data/MichaelScottData.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; + +namespace FakerDotNet.Data +{ + internal static class MichaelScottData + { + public static readonly IEnumerable Quotes = new[] + { + "Would I rather be feared or loved? Easy. Both. I want people to be afraid of how much they love me.", + "Dwight, you ignorant slut!", + "If I had a gun with two bullets and I was in a room with Hitler, Bin Laden, and Toby, I would shoot Toby twice.", + "You wanna hear a lie? ... I...think you're great. You're my best friend.", + "Webster's Dictionary defines wedding as: The fusing of two metals with a hot torch.", + "Sometimes I'll start a sentence and I don't even know where it's going. I just hope I find it along the way.", + "There were these huge bins of clothes and everybody was rifling through them like crazy. And I grabbed one and it fit! So I don't think that this is totally just a woman's suit. At the very least it's bisexual.", + "The worst thing about prison was the Dementors. They were flying all over the place and they were scary and they'd come down and they'd suck the soul out of your body and it hurt!", + "I feel like all my kids grew up, and then they married each other. It's every parents' dream.", + "You don't know me, you've just seen my penis.", + "St. Patrick's Day is the closest thing the Irish have to Christmas.", + "I am Beyoncé, always.", + "And I knew exactly what to do. But in a much more real sense, I had no idea what to do.", + "When the son of the deposed king of Nigeria emails you directly, asking for help, you help! His father ran the freaking country! Ok?", + "I have cause. It is beCAUSE I hate him.", + "I am running away from my responsibilities. And it feels good.", + "Society teaches us that having feelings and crying is bad and wrong. Well, that's baloney, because grief isn't wrong. There's such a thing as good grief. Just ask Charlie Brown.", + "Saw Inception. Or at least I dreamt I did.", + "I'm an early bird and I'm a night owl. So I'm wise and I have worms.", + "Number 8. Learn how to take off a woman's bra: You just twist your hand until something breaks.", + "I love my employees even though I hit one of you with my car.", + "You know what they say. 'Fool me once, strike one, but fool me twice...strike three.", + "I am downloading some NP# music.", + "I am dead inside.", + "WHERE ARE THE TURTLES?!", + "Welcome back, Jerky Jerk-Face.", + "Should have burned this place down when I had the chance.", + "Well, just tell him to call me as asap as possible.", + "Well, happy birthday, Jesus. Sorry your party's so lame.", + "Do you think that doing alcohol is cool?", + "I love inside jokes. Love to be a part of one someday.", + "That's what she said.", + "No, I'm not going to tell them about the downsizing. If a patient has cancer, you don't tell them.", + "There is no such thing as an appropriate joke, that's why it's a joke.", + "You may look around and see two groups here: white collar, blue collar. But I don't see it that way, and you know why not? Because I am collar-blind.", + "I would not miss it for the world. But if something else came up I would definitely not go.", + "I don't come up with this stuff, I just forward it along. You wouldn't arrest the guy who was just passing drugs from one guy to another.", + "Make friends first, make sales second, make love third. In no particular order.", + "It's a pimple, Phyllis. Avril Lavigne gets them all the time and she rocks harder than anyone alive.", + "Wikipedia is the best thing ever. Anyone in the world can write anything they want about any subject. So you know you are getting the best possible information." + }; + } +} diff --git a/src/FakerDotNet/Faker.cs b/src/FakerDotNet/Faker.cs index 54229e5..0bb38fa 100644 --- a/src/FakerDotNet/Faker.cs +++ b/src/FakerDotNet/Faker.cs @@ -39,6 +39,7 @@ public static class Faker public static ILoremFlickrFaker LoremFlickr { get; } = Container.LoremFlickr; public static ILoremPixelFaker LoremPixel { get; } = Container.LoremPixel; public static IMatzFaker Matz { get; } = Container.Matz; + public static IMichaelScottFaker MichaelScott { get; } = Container.MichaelScott; public static IMusicFaker Music { get; } = Container.Music; public static INameFaker Name { get; } = Container.Name; public static INumberFaker Number { get; } = Container.Number; diff --git a/src/FakerDotNet/FakerContainer.cs b/src/FakerDotNet/FakerContainer.cs index 075a22d..f59b863 100644 --- a/src/FakerDotNet/FakerContainer.cs +++ b/src/FakerDotNet/FakerContainer.cs @@ -37,6 +37,7 @@ internal interface IFakerContainer ILoremFlickrFaker LoremFlickr { get; } ILoremPixelFaker LoremPixel { get; } IMatzFaker Matz { get; } + IMichaelScottFaker MichaelScott { get; } IMusicFaker Music { get; } INameFaker Name { get; } INumberFaker Number { get; } @@ -96,6 +97,7 @@ public FakerContainer() LoremFlickr = new LoremFlickrFaker(this); LoremPixel = new LoremPixelFaker(this); Matz = new MatzFaker(this); + MichaelScott = new MichaelScottFaker(this); Music = new MusicFaker(this); Name = new NameFaker(this); Number = new NumberFaker(); @@ -151,6 +153,7 @@ public FakerContainer() public ILoremFlickrFaker LoremFlickr { get; } public ILoremPixelFaker LoremPixel { get; } public IMatzFaker Matz { get; } + public IMichaelScottFaker MichaelScott { get; } public IMusicFaker Music { get; } public INameFaker Name { get; } public INumberFaker Number { get; } diff --git a/src/FakerDotNet/Fakers/MichaelScottFaker.cs b/src/FakerDotNet/Fakers/MichaelScottFaker.cs new file mode 100644 index 0000000..2e8d519 --- /dev/null +++ b/src/FakerDotNet/Fakers/MichaelScottFaker.cs @@ -0,0 +1,24 @@ +using FakerDotNet.Data; + +namespace FakerDotNet.Fakers +{ + public interface IMichaelScottFaker + { + string Quote(); + } + + internal class MichaelScottFaker : IMichaelScottFaker + { + private readonly IFakerContainer _fakerContainer; + + public MichaelScottFaker(IFakerContainer fakerContainer) + { + _fakerContainer = fakerContainer; + } + + public string Quote() + { + return _fakerContainer.Random.Element(MichaelScottData.Quotes); + } + } +} diff --git a/tests/FakerDotNet.Tests/FakerContainerTests.cs b/tests/FakerDotNet.Tests/FakerContainerTests.cs index b355868..be880ad 100644 --- a/tests/FakerDotNet.Tests/FakerContainerTests.cs +++ b/tests/FakerDotNet.Tests/FakerContainerTests.cs @@ -213,6 +213,12 @@ public void Matz_returns_IMatzFaker() Assert.IsInstanceOf(_fakerContainer.Matz); } + [Test] + public void MichaelScott_returns_IMichaelScottFaker() + { + Assert.IsInstanceOf(_fakerContainer.MichaelScott); + } + [Test] public void Music_returns_IMusicFaker() { diff --git a/tests/FakerDotNet.Tests/FakerTests.cs b/tests/FakerDotNet.Tests/FakerTests.cs index 368edc5..2c11d2d 100644 --- a/tests/FakerDotNet.Tests/FakerTests.cs +++ b/tests/FakerDotNet.Tests/FakerTests.cs @@ -205,6 +205,12 @@ public void Matz_returns_IMatzFaker() Assert.IsInstanceOf(Faker.Matz); } + [Test] + public void MichaelScott_returns_IMichaelScottFaker() + { + Assert.IsInstanceOf(Faker.MichaelScott); + } + [Test] public void Music_returns_IMusicFaker() { diff --git a/tests/FakerDotNet.Tests/Fakers/MichaelScottFakerTests.cs b/tests/FakerDotNet.Tests/Fakers/MichaelScottFakerTests.cs new file mode 100644 index 0000000..b465c05 --- /dev/null +++ b/tests/FakerDotNet.Tests/Fakers/MichaelScottFakerTests.cs @@ -0,0 +1,31 @@ +using FakeItEasy; +using FakerDotNet.Data; +using FakerDotNet.Fakers; +using NUnit.Framework; + +namespace FakerDotNet.Tests.Fakers +{ + [TestFixture] + [Parallelizable] + public class MichaelScottFakerTests + { + [SetUp] + public void SetUp() + { + _fakerContainer = A.Fake(); + _michaelScottFaker = new MichaelScottFaker(_fakerContainer); + } + + private IFakerContainer _fakerContainer; + private IMichaelScottFaker _michaelScottFaker; + + [Test] + public void Quote_returns_a_quote() + { + A.CallTo(() => _fakerContainer.Random.Element(MichaelScottData.Quotes)) + .Returns("I am Beyoncé, always."); + + Assert.AreEqual("I am Beyoncé, always.", _michaelScottFaker.Quote()); + } + } +}