-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added the documentation. * Added the data for the Hacker faker. * Implemented the Hacker faker. * Added the HackerFaker to the main faker classes.
- Loading branch information
Showing
9 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Faker.Hacker | ||
|
||
Are you having trouble writing tech-savvy dialogue for your latest screenplay? | ||
Worry not! Hollywood-grade technical talk is ready to fill out any form where you need to look smart. | ||
|
||
```cs | ||
// Full Phrase | ||
Faker.Hacker.SaySomethingSmart() //=> "Try to compress the SQL interface, maybe it will program the back-end hard drive!" | ||
// Short technical abbreviations | ||
Faker.Hacker.Abbreviation() //=> "RAM" | ||
// Hacker centric adjectives | ||
Faker.Hacker.Adjective() //=> "open-source" | ||
// Only the best hacker related nouns | ||
Faker.Hacker.Noun() //=> "bandwidth" | ||
// Actions that hackers take | ||
Faker.Hacker.Verb() //=> "bypass" | ||
// Verbs that end in -ing | ||
Faker.Hacker.Ingverb() //=> "synthesizing" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FakerDotNet.Data | ||
{ | ||
internal static class HackerData | ||
{ | ||
public static readonly IEnumerable<string> Abbreviations = new[] | ||
{ | ||
"TCP", | ||
"HTTP", | ||
"SDD", | ||
"RAM", | ||
"GB", | ||
"CSS", | ||
"SSL", | ||
"AGP", | ||
"SQL", | ||
"FTP", | ||
"PCI", | ||
"AI", | ||
"ADP", | ||
"RSS", | ||
"XML", | ||
"EXE", | ||
"COM", | ||
"HDD", | ||
"THX", | ||
"SMTP", | ||
"SMS", | ||
"USB", | ||
"PNG", | ||
"SAS", | ||
"IB", | ||
"SCSI", | ||
"JSON", | ||
"XSS", | ||
"JBOD" | ||
}; | ||
|
||
public static readonly IEnumerable<string> Adjectives = new[] | ||
{ | ||
"auxiliary", | ||
"primary", | ||
"back-end", | ||
"digital", | ||
"open-source", | ||
"virtual", | ||
"cross-platform", | ||
"redundant", | ||
"online", | ||
"haptic", | ||
"multi-byte", | ||
"bluetooth", | ||
"wireless", | ||
"1080p", | ||
"neural, optical", | ||
"solid state", | ||
"mobile" | ||
}; | ||
|
||
public static readonly IEnumerable<string> Nouns = new[] | ||
{ | ||
"driver", | ||
"protocol", | ||
"bandwidth", | ||
"panel", | ||
"microchip", | ||
"program", | ||
"port", | ||
"card", | ||
"array", | ||
"interface", | ||
"system", | ||
"sensor", | ||
"firewall", | ||
"hard drive", | ||
"pixel", | ||
"alarm", | ||
"feed", | ||
"monitor", | ||
"application", | ||
"transmitter", | ||
"bus", | ||
"circuit", | ||
"capacitor", | ||
"matrix" | ||
}; | ||
|
||
public static readonly IEnumerable<string> Verbs = new[] | ||
{ | ||
"back up", | ||
"bypass", | ||
"hack", | ||
"override", | ||
"compress", | ||
"copy", | ||
"navigate", | ||
"index", | ||
"connect", | ||
"generate", | ||
"quantify", | ||
"calculate", | ||
"synthesize", | ||
"input", | ||
"transmit", | ||
"program", | ||
"reboot", | ||
"parse" | ||
}; | ||
|
||
public static readonly IEnumerable<string> Ingverbs = new[] | ||
{ | ||
"backing up", | ||
"bypassing", | ||
"hacking", | ||
"overriding", | ||
"compressing", | ||
"copying", | ||
"navigating", | ||
"indexing", | ||
"connecting", | ||
"generating", | ||
"quantifying", | ||
"calculating, synthesizing", | ||
"transmitting", | ||
"programming", | ||
"parsing" | ||
}; | ||
|
||
public static readonly IEnumerable<string> Phrases = new[] | ||
{ | ||
"If we {Verb} the {Noun}, we can get to the {Abbreviation} {Noun} through the {Adjective} {Abbreviation} {Noun}!", | ||
"We need to {Verb} the {Adjective} {Abbreviation} {Noun}!", | ||
"Try to {Verb} the {Abbreviation} {Noun}, maybe it will {Verb} the {Adjective} {Noun}!", | ||
"You can't {Verb} the {Noun} without {Ingverb} the {Adjective} {Abbreviation} {Noun}!", | ||
"Use the {Adjective} {Abbreviation} {Noun}, then you can {Verb} the {Adjective} {Noun}!", | ||
"The {Abbreviation} {Noun} is down, {Verb} the {Adjective} {Noun} so we can {Verb} the {Abbreviation} {Noun}!", | ||
"{Ingverb} the {Noun} won't do anything, we need to {Verb} the {Adjective} {Abbreviation} {Noun}!", | ||
"I'll {Verb} the {Adjective} {Abbreviation} {Noun}, that should {Noun} the {Abbreviation} {Noun}!" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Text.RegularExpressions; | ||
using FakerDotNet.Data; | ||
|
||
namespace FakerDotNet.Fakers | ||
{ | ||
public interface IHackerFaker | ||
{ | ||
string SaySomethingSmart(); | ||
string Abbreviation(); | ||
string Adjective(); | ||
string Noun(); | ||
string Verb(); | ||
string Ingverb(); | ||
} | ||
|
||
internal class HackerFaker : IHackerFaker | ||
{ | ||
private readonly IFakerContainer _fakerContainer; | ||
|
||
public HackerFaker(IFakerContainer fakerContainer) | ||
{ | ||
_fakerContainer = fakerContainer; | ||
} | ||
|
||
public string SaySomethingSmart() | ||
{ | ||
return Parse(_fakerContainer.Random.Element(HackerData.Phrases)); | ||
} | ||
|
||
public string Abbreviation() | ||
{ | ||
return _fakerContainer.Random.Element(HackerData.Abbreviations); | ||
} | ||
|
||
public string Adjective() | ||
{ | ||
return _fakerContainer.Random.Element(HackerData.Adjectives); | ||
} | ||
|
||
public string Noun() | ||
{ | ||
return _fakerContainer.Random.Element(HackerData.Nouns); | ||
} | ||
|
||
public string Verb() | ||
{ | ||
return _fakerContainer.Random.Element(HackerData.Verbs); | ||
} | ||
|
||
public string Ingverb() | ||
{ | ||
return _fakerContainer.Random.Element(HackerData.Ingverbs); | ||
} | ||
|
||
private string Parse(string format) | ||
{ | ||
var text = Regex.Replace(format, @"\{(\w+)\}", @"{Hacker.$1}"); | ||
|
||
return _fakerContainer.Fake.F(text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using FakeItEasy; | ||
using FakerDotNet.Data; | ||
using FakerDotNet.Fakers; | ||
using NUnit.Framework; | ||
|
||
namespace FakerDotNet.Tests.Fakers | ||
{ | ||
[TestFixture] | ||
[Parallelizable] | ||
public class HackerFakerTests | ||
{ | ||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_fakerContainer = A.Fake<IFakerContainer>(); | ||
_hackerFaker = new HackerFaker(_fakerContainer); | ||
|
||
A.CallTo(() => _fakerContainer.Fake).Returns(new FakeFaker(_fakerContainer)); | ||
} | ||
|
||
private IFakerContainer _fakerContainer; | ||
private IHackerFaker _hackerFaker; | ||
|
||
[Test] | ||
public void SaySomethingSmart_returns_something_smart() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Phrases)) | ||
.Returns("Try to {Verb} the {Abbreviation} {Noun}, maybe it will {Verb} the {Adjective} {Noun}!"); | ||
A.CallTo(() => _fakerContainer.Hacker.Verb()) | ||
.ReturnsNextFromSequence("compress", "program"); | ||
A.CallTo(() => _fakerContainer.Hacker.Abbreviation()) | ||
.Returns("SQL"); | ||
A.CallTo(() => _fakerContainer.Hacker.Noun()) | ||
.ReturnsNextFromSequence("interface", "hard drive"); | ||
A.CallTo(() => _fakerContainer.Hacker.Adjective()) | ||
.Returns("back-end"); | ||
|
||
Assert.AreEqual( | ||
"Try to compress the SQL interface, maybe it will program the back-end hard drive!", | ||
_hackerFaker.SaySomethingSmart()); | ||
} | ||
|
||
[Test] | ||
public void Abbreviation_returns_an_abbreviation() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Abbreviations)) | ||
.Returns("RAM"); | ||
|
||
Assert.AreEqual("RAM", _hackerFaker.Abbreviation()); | ||
} | ||
|
||
[Test] | ||
public void Adjective_returns_an_adjective() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Adjectives)) | ||
.Returns("open-source"); | ||
|
||
Assert.AreEqual("open-source", _hackerFaker.Adjective()); | ||
} | ||
|
||
[Test] | ||
public void Noun_returns_a_noun() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Nouns)) | ||
.Returns("bandwidth"); | ||
|
||
Assert.AreEqual("bandwidth", _hackerFaker.Noun()); | ||
} | ||
|
||
[Test] | ||
public void Verb_returns_a_verb() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Verbs)) | ||
.Returns("bypass"); | ||
|
||
Assert.AreEqual("bypass", _hackerFaker.Verb()); | ||
} | ||
|
||
[Test] | ||
public void Ingverb_returns_an_ing_ending_verb() | ||
{ | ||
A.CallTo(() => _fakerContainer.Random.Element(HackerData.Ingverbs)) | ||
.Returns("synthesizing"); | ||
|
||
Assert.AreEqual("synthesizing", _hackerFaker.Ingverb()); | ||
} | ||
} | ||
} |