Skip to content

Commit

Permalink
Merge ca135b6 into 312fc14
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstebo committed Nov 27, 2018
2 parents 312fc14 + ca135b6 commit 07ffc55
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ A .NET port of the Ruby [faker](https://github.com/stympy/faker) gem
- [Installing](#installing)
- [Usage](#usage)
- [Faker.Address](doc/address.md)
- [Faker.Ancient](doc/ancient.md)
- [Faker.App](doc/app.md)
- [Faker.Avatar](doc/avatar.md)
- [Faker.Beer](doc/beer.md)
Expand Down
13 changes: 13 additions & 0 deletions doc/ancient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Faker.Ancient

Available since version 1.7.0.

```cs
Faker.Ancient.God() //=> "Zeus"
Faker.Ancient.Primordial() //=> "Gaia"
Faker.Ancient.Titan() //=> "Atlas"
Faker.Ancient.Hero() //=> "Achilles"
```
147 changes: 147 additions & 0 deletions src/FakerDotNet/Data/AncientData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using System.Collections.Generic;

namespace FakerDotNet.Data
{
internal static class AncientData
{
public static readonly IEnumerable<string> Gods = new[]
{
"Aphrodite",
"Apollo",
"Ares",
"Artemis",
"Athena",
"Demeter",
"Dionysus",
"Hades",
"Hephaestus",
"Hera",
"Hermes",
"Hestia",
"Poseidon",
"Zeus"
};

public static readonly IEnumerable<string> Primordials = new[]
{
"Aion",
"Aether",
"Ananke",
"Chaos",
"Chronos",
"Erebus",
"Eros",
"Hypnos",
"Nesoi",
"Uranus",
"Gaia",
"Ourea",
"Phanes",
"Pontus",
"Tartarus",
"Thalassa",
"Thanatos",
"Hemera",
"Nyx",
"Nemesis"
};

public static readonly IEnumerable<string> Titans = new[]
{
"Coeus",
"Crius",
"Cronus",
"Hyperion",
"Iapetus",
"Mnemosyne",
"Oceanus",
"Phoebe",
"Rhea",
"Tethys",
"Theia",
"Themis",
"Asteria",
"Astraeus",
"Atlas",
"Aura",
"Clymene",
"Dione",
"Helios",
"Selene",
"Eos",
"Epimetheus",
"Eurybia",
"Eurynome",
"Lelantos",
"Leto",
"Menoetius",
"Metis",
"Ophion",
"Pallas",
"Perses",
"Prometheus",
"Styx"
};

public static readonly IEnumerable<string> Heroes = new[]
{
"Abderus",
"Achilles",
"Aeneas",
"Ajax",
"Amphitryon",
"Antilochus",
"Bellerophon",
"Castor",
"Chrysippus",
"Daedalus",
"Diomedes",
"Eleusis",
"Eunostus",
"Ganymede",
"Hector",
"Hercules",
"Icarus",
"Iolaus",
"Jason",
"Meleager",
"Odysseus",
"Orpheus",
"Pandion",
"Perseus",
"Theseus",
"Alcestis",
"Amymone",
"Andromache",
"Andromeda",
"Antigone",
"Arachne",
"Ariadne",
"Atalanta",
"Briseis",
"Caeneus",
"Cassandra",
"Cassiopeia",
"Clytemnestra",
"Danaë",
"Deianeira",
"Electra",
"Europa",
"Hecuba",
"Helen",
"Hermione",
"Iphigenia",
"Ismene",
"Jocasta",
"Medea",
"Medusa",
"Niobe",
"Pandora",
"Penelope",
"Phaedra",
"Polyxena",
"Semele",
"Thrace"
};
}
}
1 change: 1 addition & 0 deletions src/FakerDotNet/Faker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static class Faker
private static readonly IFakerContainer Container = new FakerContainer();

public static IAddressFaker Address { get; } = Container.Address;
public static IAncientFaker Ancient { get; } = Container.Ancient;
public static IAppFaker App { get; } = Container.App;
public static IAvatarFaker Avatar { get; } = Container.Avatar;
public static IBeerFaker Beer { get; } = Container.Beer;
Expand Down
3 changes: 3 additions & 0 deletions src/FakerDotNet/FakerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace FakerDotNet
internal interface IFakerContainer
{
IAddressFaker Address { get; }
IAncientFaker Ancient { get; }
IAppFaker App { get; }
IAvatarFaker Avatar { get; }
IBeerFaker Beer { get; }
Expand Down Expand Up @@ -42,6 +43,7 @@ internal class FakerContainer : IFakerContainer
public FakerContainer()
{
Address = new AddressFaker(this);
Ancient = new AncientFaker(this);
App = new AppFaker(this);
Avatar = new AvatarFaker(this);
Beer = new BeerFaker(this);
Expand Down Expand Up @@ -75,6 +77,7 @@ public FakerContainer()
}

public IAddressFaker Address { get; }
public IAncientFaker Ancient { get; }
public IAppFaker App { get; }
public IAvatarFaker Avatar { get; }
public IBeerFaker Beer { get; }
Expand Down
42 changes: 42 additions & 0 deletions src/FakerDotNet/Fakers/AncientFaker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using FakerDotNet.Data;

namespace FakerDotNet.Fakers
{
public interface IAncientFaker
{
string God();
string Primordial();
string Titan();
string Hero();
}

internal class AncientFaker : IAncientFaker
{
private readonly IFakerContainer _fakerContainer;

public AncientFaker(IFakerContainer fakerContainer)
{
_fakerContainer = fakerContainer;
}

public string God()
{
return _fakerContainer.Random.Element(AncientData.Gods);
}

public string Primordial()
{
return _fakerContainer.Random.Element(AncientData.Primordials);
}

public string Titan()
{
return _fakerContainer.Random.Element(AncientData.Titans);
}

public string Hero()
{
return _fakerContainer.Random.Element(AncientData.Heroes);
}
}
}
6 changes: 6 additions & 0 deletions tests/FakerDotNet.Tests/FakerContainerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public void Address_returns_IAddressFaker()
Assert.IsInstanceOf<IAddressFaker>(_fakerContainer.Address);
}

[Test]
public void Ancient_returns_IAncientFaker()
{
Assert.IsInstanceOf<IAncientFaker>(_fakerContainer.Ancient);
}

[Test]
public void App_returns_IAppFaker()
{
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 @@ -13,6 +13,12 @@ public void Address_returns_IAddressFaker()
Assert.IsInstanceOf<IAddressFaker>(Faker.Address);
}

[Test]
public void Ancient_returns_IAncientFaker()
{
Assert.IsInstanceOf<IAncientFaker>(Faker.Ancient);
}

[Test]
public void App_returns_IAppFaker()
{
Expand Down
58 changes: 58 additions & 0 deletions tests/FakerDotNet.Tests/Fakers/AncientFakerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using FakeItEasy;
using FakerDotNet.Data;
using FakerDotNet.Fakers;
using NUnit.Framework;

namespace FakerDotNet.Tests.Fakers
{
[TestFixture]
[Parallelizable]
public class AncientFakerTests
{
[SetUp]
public void SetUp()
{
_fakerContainer = A.Fake<IFakerContainer>();
_ancientFaker = new AncientFaker(_fakerContainer);
}

private IFakerContainer _fakerContainer;
private IAncientFaker _ancientFaker;

[Test]
public void God_returns_a_god()
{
A.CallTo(() => _fakerContainer.Random.Element(AncientData.Gods))
.Returns("Zeus");

Assert.AreEqual("Zeus", _ancientFaker.God());
}

[Test]
public void Primordial_returns_a_primordial()
{
A.CallTo(() => _fakerContainer.Random.Element(AncientData.Primordials))
.Returns("Gaia");

Assert.AreEqual("Gaia", _ancientFaker.Primordial());
}

[Test]
public void Titan_returns_a_titan()
{
A.CallTo(() => _fakerContainer.Random.Element(AncientData.Titans))
.Returns("Atlas");

Assert.AreEqual("Atlas", _ancientFaker.Titan());
}

[Test]
public void Hero_returns_a_hero()
{
A.CallTo(() => _fakerContainer.Random.Element(AncientData.Heroes))
.Returns("Achilles");

Assert.AreEqual("Achilles", _ancientFaker.Hero());
}
}
}

0 comments on commit 07ffc55

Please sign in to comment.