Skip to content

Commit

Permalink
Added the MichaelScott faker. (#117)
Browse files Browse the repository at this point in the history
* Added the documentation.

* Added the data.

* Implemented the MichaelScott faker.

* Added the MichaelScott faker to the main faker classes.
  • Loading branch information
mrstebo authored Feb 14, 2019
1 parent 00d68c7 commit b5c3d78
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions doc/michael_scott.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Faker.MichaelScott

```cs
Faker.MichaelScott.Quote() //=> "I am Beyoncé, always."
```
51 changes: 51 additions & 0 deletions src/FakerDotNet/Data/MichaelScottData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;

namespace FakerDotNet.Data
{
internal static class MichaelScottData
{
public static readonly IEnumerable<string> 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."
};
}
}
1 change: 1 addition & 0 deletions src/FakerDotNet/Faker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/FakerDotNet/FakerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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; }
Expand Down
24 changes: 24 additions & 0 deletions src/FakerDotNet/Fakers/MichaelScottFaker.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
6 changes: 6 additions & 0 deletions tests/FakerDotNet.Tests/FakerContainerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public void Matz_returns_IMatzFaker()
Assert.IsInstanceOf<IMatzFaker>(_fakerContainer.Matz);
}

[Test]
public void MichaelScott_returns_IMichaelScottFaker()
{
Assert.IsInstanceOf<IMichaelScottFaker>(_fakerContainer.MichaelScott);
}

[Test]
public void Music_returns_IMusicFaker()
{
Expand Down
6 changes: 6 additions & 0 deletions tests/FakerDotNet.Tests/FakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ public void Matz_returns_IMatzFaker()
Assert.IsInstanceOf<IMatzFaker>(Faker.Matz);
}

[Test]
public void MichaelScott_returns_IMichaelScottFaker()
{
Assert.IsInstanceOf<IMichaelScottFaker>(Faker.MichaelScott);
}

[Test]
public void Music_returns_IMusicFaker()
{
Expand Down
31 changes: 31 additions & 0 deletions tests/FakerDotNet.Tests/Fakers/MichaelScottFakerTests.cs
Original file line number Diff line number Diff line change
@@ -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<IFakerContainer>();
_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());
}
}
}

0 comments on commit b5c3d78

Please sign in to comment.