Skip to content

Commit b5c3d78

Browse files
authored
Added the MichaelScott faker. (#117)
* Added the documentation. * Added the data. * Implemented the MichaelScott faker. * Added the MichaelScott faker to the main faker classes.
1 parent 00d68c7 commit b5c3d78

File tree

9 files changed

+128
-0
lines changed

9 files changed

+128
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ A .NET port of the Ruby [faker](https://github.com/stympy/faker) gem
4242
- [Faker.LoremFlickr](doc/lorem_flickr.md)
4343
- [Faker.LoremPixel](doc/lorem_pixel.md)
4444
- [Faker.Matz](doc/matz.md)
45+
- [Faker.MichaelScott](doc/michael_scott.md)
4546
- [Faker.Music](doc/music.md)
4647
- [Faker.Name](doc/name.md)
4748
- [Faker.Number](doc/number.md)

doc/michael_scott.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Faker.MichaelScott
2+
3+
```cs
4+
Faker.MichaelScott.Quote() //=> "I am Beyoncé, always."
5+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Collections.Generic;
2+
3+
namespace FakerDotNet.Data
4+
{
5+
internal static class MichaelScottData
6+
{
7+
public static readonly IEnumerable<string> Quotes = new[]
8+
{
9+
"Would I rather be feared or loved? Easy. Both. I want people to be afraid of how much they love me.",
10+
"Dwight, you ignorant slut!",
11+
"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.",
12+
"You wanna hear a lie? ... I...think you're great. You're my best friend.",
13+
"Webster's Dictionary defines wedding as: The fusing of two metals with a hot torch.",
14+
"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.",
15+
"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.",
16+
"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!",
17+
"I feel like all my kids grew up, and then they married each other. It's every parents' dream.",
18+
"You don't know me, you've just seen my penis.",
19+
"St. Patrick's Day is the closest thing the Irish have to Christmas.",
20+
"I am Beyoncé, always.",
21+
"And I knew exactly what to do. But in a much more real sense, I had no idea what to do.",
22+
"When the son of the deposed king of Nigeria emails you directly, asking for help, you help! His father ran the freaking country! Ok?",
23+
"I have cause. It is beCAUSE I hate him.",
24+
"I am running away from my responsibilities. And it feels good.",
25+
"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.",
26+
"Saw Inception. Or at least I dreamt I did.",
27+
"I'm an early bird and I'm a night owl. So I'm wise and I have worms.",
28+
"Number 8. Learn how to take off a woman's bra: You just twist your hand until something breaks.",
29+
"I love my employees even though I hit one of you with my car.",
30+
"You know what they say. 'Fool me once, strike one, but fool me twice...strike three.",
31+
"I am downloading some NP# music.",
32+
"I am dead inside.",
33+
"WHERE ARE THE TURTLES?!",
34+
"Welcome back, Jerky Jerk-Face.",
35+
"Should have burned this place down when I had the chance.",
36+
"Well, just tell him to call me as asap as possible.",
37+
"Well, happy birthday, Jesus. Sorry your party's so lame.",
38+
"Do you think that doing alcohol is cool?",
39+
"I love inside jokes. Love to be a part of one someday.",
40+
"That's what she said.",
41+
"No, I'm not going to tell them about the downsizing. If a patient has cancer, you don't tell them.",
42+
"There is no such thing as an appropriate joke, that's why it's a joke.",
43+
"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.",
44+
"I would not miss it for the world. But if something else came up I would definitely not go.",
45+
"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.",
46+
"Make friends first, make sales second, make love third. In no particular order.",
47+
"It's a pimple, Phyllis. Avril Lavigne gets them all the time and she rocks harder than anyone alive.",
48+
"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."
49+
};
50+
}
51+
}

src/FakerDotNet/Faker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static class Faker
3939
public static ILoremFlickrFaker LoremFlickr { get; } = Container.LoremFlickr;
4040
public static ILoremPixelFaker LoremPixel { get; } = Container.LoremPixel;
4141
public static IMatzFaker Matz { get; } = Container.Matz;
42+
public static IMichaelScottFaker MichaelScott { get; } = Container.MichaelScott;
4243
public static IMusicFaker Music { get; } = Container.Music;
4344
public static INameFaker Name { get; } = Container.Name;
4445
public static INumberFaker Number { get; } = Container.Number;

src/FakerDotNet/FakerContainer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ internal interface IFakerContainer
3737
ILoremFlickrFaker LoremFlickr { get; }
3838
ILoremPixelFaker LoremPixel { get; }
3939
IMatzFaker Matz { get; }
40+
IMichaelScottFaker MichaelScott { get; }
4041
IMusicFaker Music { get; }
4142
INameFaker Name { get; }
4243
INumberFaker Number { get; }
@@ -96,6 +97,7 @@ public FakerContainer()
9697
LoremFlickr = new LoremFlickrFaker(this);
9798
LoremPixel = new LoremPixelFaker(this);
9899
Matz = new MatzFaker(this);
100+
MichaelScott = new MichaelScottFaker(this);
99101
Music = new MusicFaker(this);
100102
Name = new NameFaker(this);
101103
Number = new NumberFaker();
@@ -151,6 +153,7 @@ public FakerContainer()
151153
public ILoremFlickrFaker LoremFlickr { get; }
152154
public ILoremPixelFaker LoremPixel { get; }
153155
public IMatzFaker Matz { get; }
156+
public IMichaelScottFaker MichaelScott { get; }
154157
public IMusicFaker Music { get; }
155158
public INameFaker Name { get; }
156159
public INumberFaker Number { get; }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using FakerDotNet.Data;
2+
3+
namespace FakerDotNet.Fakers
4+
{
5+
public interface IMichaelScottFaker
6+
{
7+
string Quote();
8+
}
9+
10+
internal class MichaelScottFaker : IMichaelScottFaker
11+
{
12+
private readonly IFakerContainer _fakerContainer;
13+
14+
public MichaelScottFaker(IFakerContainer fakerContainer)
15+
{
16+
_fakerContainer = fakerContainer;
17+
}
18+
19+
public string Quote()
20+
{
21+
return _fakerContainer.Random.Element(MichaelScottData.Quotes);
22+
}
23+
}
24+
}

tests/FakerDotNet.Tests/FakerContainerTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ public void Matz_returns_IMatzFaker()
213213
Assert.IsInstanceOf<IMatzFaker>(_fakerContainer.Matz);
214214
}
215215

216+
[Test]
217+
public void MichaelScott_returns_IMichaelScottFaker()
218+
{
219+
Assert.IsInstanceOf<IMichaelScottFaker>(_fakerContainer.MichaelScott);
220+
}
221+
216222
[Test]
217223
public void Music_returns_IMusicFaker()
218224
{

tests/FakerDotNet.Tests/FakerTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public void Matz_returns_IMatzFaker()
205205
Assert.IsInstanceOf<IMatzFaker>(Faker.Matz);
206206
}
207207

208+
[Test]
209+
public void MichaelScott_returns_IMichaelScottFaker()
210+
{
211+
Assert.IsInstanceOf<IMichaelScottFaker>(Faker.MichaelScott);
212+
}
213+
208214
[Test]
209215
public void Music_returns_IMusicFaker()
210216
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using FakeItEasy;
2+
using FakerDotNet.Data;
3+
using FakerDotNet.Fakers;
4+
using NUnit.Framework;
5+
6+
namespace FakerDotNet.Tests.Fakers
7+
{
8+
[TestFixture]
9+
[Parallelizable]
10+
public class MichaelScottFakerTests
11+
{
12+
[SetUp]
13+
public void SetUp()
14+
{
15+
_fakerContainer = A.Fake<IFakerContainer>();
16+
_michaelScottFaker = new MichaelScottFaker(_fakerContainer);
17+
}
18+
19+
private IFakerContainer _fakerContainer;
20+
private IMichaelScottFaker _michaelScottFaker;
21+
22+
[Test]
23+
public void Quote_returns_a_quote()
24+
{
25+
A.CallTo(() => _fakerContainer.Random.Element(MichaelScottData.Quotes))
26+
.Returns("I am Beyoncé, always.");
27+
28+
Assert.AreEqual("I am Beyoncé, always.", _michaelScottFaker.Quote());
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)