diff --git a/README.md b/README.md index 8439c50..b20a2a6 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ A .NET port of the Ruby [faker](https://github.com/stympy/faker) gem - [Faker.RickAndMorty](doc/rick_and_morty.md) - [Faker.RockBand](doc/rockband.md) - [Faker.SlackEmoji](doc/slackemoji.md) + - [Faker.Space](doc/space.md) - [Faker.StarWars](doc/star_wars.md) - [Faker.Superhero](doc/superhero.md) - [Faker.Team](doc/team.md) diff --git a/doc/space.md b/doc/space.md new file mode 100644 index 0000000..d171815 --- /dev/null +++ b/doc/space.md @@ -0,0 +1,45 @@ +// Faker.Space + +```cs +// Random planet from our Solar System +Faker.Space.Planet() //=> "Venus" + +// Random moon from our Solar System +Faker.Space.Moon() //=> "Europa" + +// Random galaxy +Faker.Space.Galaxy() //=> "Andromeda" + +// Random nebula name +Faker.Space.Nebula() //=> "Triffid Nebula" + +// Random star cluster +Faker.Space.StarCluster() //=> "Messier 70" + +// Random constellation +Faker.Space.Constellation() //=> "Orion" + +// Random star +Faker.Space.Star() //=> "Proxima Centauri" + +// Random national space agency +Faker.Space.Agency() //=> "Japan Aerospace Exploration Agency" + +// Random space agency abbreviation +Faker.Space.AgencyAbv() //=> "NASA" + +// Random spacecraft name (limited to NASA) +Faker.Space.NaseSpaceCraft() //=> "Endeavour" + +// Random private space company title +Faker.Space.Company() //=> "SpaceX" + +// Random unit of stellar distance with number +Faker.Space.DistanceMeasurement() //=> "15 parsecs" + +// Random meteorite name +Faker.Space.Meteorite() //=> "Ensisheim" + +// Random launch vehicule name +Faker.Space.LaunchVehicle() //=> "Saturn IV" +``` \ No newline at end of file diff --git a/src/FakerDotNet/Data/SpaceData.cs b/src/FakerDotNet/Data/SpaceData.cs new file mode 100644 index 0000000..f66fa35 --- /dev/null +++ b/src/FakerDotNet/Data/SpaceData.cs @@ -0,0 +1,401 @@ +using System.Collections.Generic; + +namespace FakerDotNet.Data +{ + internal static class SpaceData + { + public static readonly IEnumerable Planets = new[] + { + "Mercury", + "Venus", + "Earth", + "Mars", + "Jupiter", + "Saturn", + "Uranus", + "Neptune" + }; + + public static readonly IEnumerable Moons = new[] + { + "Moon", + "Luna", + "Deimos", + "Phobos", + "Ganymede", + "Callisto", + "Io", + "Europa", + "Titan", + "Rhea", + "Iapetus", + "Dione", + "Tethys", + "Hyperion", + "Ariel", + "Puck", + "Oberon", + "Umbriel", + "Triton", + "Proteus" + }; + + public static readonly IEnumerable Galaxies = new[] + { + "Milky Way", + "Andromeda", + "Triangulum", + "Whirlpool", + "Blackeye", + "Sunflower", + "Pinwheel", + "Hoags Object", + "Centaurus A", + "Messier 83" + }; + + public static readonly IEnumerable Nebulas = new[] + { + "Lagoon Nebula", + "Eagle Nebula", + "Triffid Nebula", + "Dumbell Nebula", + "Orion Nebula", + "Ring Nebula", + "Bodes Nebula", + "Owl Nebula" + }; + + public static readonly IEnumerable StarClusters = new[] + { + "Wild Duck", + "Hyades", + "Coma", + "Butterfly", + "Messier 7", + "Pleiades", + "Beehive Cluster", + "Pearl Cluster", + "Hodge 301", + "Jewel Box Cluster", + "Wishing Well Cluster", + "Diamond Cluster", + "Trumpler 10", + "Collinder 140", + "Liller 1", + "Koposov II", + "Koposov I", + "Djorgovski 1", + "Arp-Madore 1", + "NGC 6144", + "NGC 2808", + "NGC 1783", + "Messier 107", + "Messier 70", + "Omega Centauri", + "Palomar 12", + "Palomar 4", + "Palomar 6", + "Pyxis Cluster", + "Segue 3" + }; + + public static readonly IEnumerable Constellations = new[] + { + "Big Dipper", + "Litte Dipper", + "Orion", + "Loe", + "Gemini", + "Cancer", + "Canis Minor", + "Canis Major", + "Ursa Major", + "Ursa Minor", + "Virgo", + "Libra", + "Scorpius", + "Sagittarius", + "Lyra", + "Capricornus", + "Aquarius", + "Pisces", + "Aries", + "Leo Minor", + "Auriga" + }; + + public static readonly IEnumerable Stars = new[] + { + "Sun", + "Proxima Centauri", + "Rigil Kentaurus", + "Barnards Star", + "Wolf 359", + "Luyten 726-8A", + "Luyten 726-8B", + "Sirius A", + "Sirius B", + "Ross 154", + "Ross 248", + "Procyon A", + "Procyon B", + "Vega", + "Rigel", + "Arcturus", + "Betelgeuse", + "Mahasim", + "Polaris" + }; + + public static readonly IEnumerable Agencies = new[] + { + "National Aeronautics and Space Administration", + "European Space Agency", + "German Aerospace Center", + "Indian Space Research Organization", + "China National Space Administration", + "UK Space Agency", + "Brazilian Space Agency", + "Mexican Space Agency", + "Israeli Space Agency", + "Italian Space Agency", + "Japan Aerospace Exploration Agency", + "National Space Agency of Ukraine", + "Russian Federal Space Agency", + "Swedish National Space Board" + }; + + public static readonly IEnumerable AgencyAbvs = new[] + { + "NASA", + "AEM", + "AEB", + "UKSA", + "CSA", + "CNSA", + "ESA", + "DLR", + "ISRO", + "JAXA", + "ISA", + "CNES", + "NSAU", + "ROSCOSMOS", + "SNSB" + }; + + public static readonly IEnumerable NasaSpaceCraft = new[] + { + "Orion", + "Mercury", + "Gemini", + "Apollo", + "Enterprise", + "Columbia", + "Challenger", + "Discovery", + "Atlantis", + "Endeavour" + }; + + public static readonly IEnumerable Companies = new[] + { + "Rocket Lab", + "SpaceX", + "Blue Origin", + "Virgin Galactic", + "SpaceDev", + "Bigelow Aerospace", + "Orbital Sciences", + "JPL", + "NASA Jet Propulsion Laboratory" + }; + + public static readonly IEnumerable DistanceMeasurements = new[] + { + "light years", + "AU", + "parsecs", + "kiloparsecs", + "megaparsecs" + }; + + public static readonly IEnumerable Meteorites = new[] + { + "Aarhus", + "Abee", + "Adelie Land", + "Adhi Kot", + "Adzhi-Bogdo", + "Santa Rosa de Viterbo", + "Agen", + "Akbarpur", + "Albareto", + "Allan Hills 84001", + "Allan Hills A81005", + "Allegan", + "Allende", + "Ambapur Nagla", + "Andura", + "Angers", + "Angra dos Reis", + "Ankober", + "Anlong", + "Annaheim", + "Appley Bridge", + "Arbol Solo", + "Archie", + "Arroyo Aguiar", + "Assisi", + "Atoka", + "Avanhandava", + "Bacubirito", + "Baszkówka","Beardsley", + "Bellsbank", + "Bench Crater", + "Benton", + "Białystok", + "Blithfield","Block Island", + "Bovedy", + "Brachina", + "Brahin", + "Brenham", + "Buzzard Coulee","Campo del Cielo", + "Canyon Diablo", + "Cape York", + "Carancas", + "Chambord","Chassigny", + "Chelyabinsk", + "Chergach", + "Chinga", + "Chinguetti", + "Claxton","Coahuila", + "Cranbourne", + "D'Orbigny", + "Dronino", + "Eagle Station", + "Elbogen","Ensisheim", + "Esquel", + "Fukang", + "Gancedo", + "Gao–Guenie", + "Gay Gulch", + "Gebel Kamil", + "Gibeon", + "Goose Lake", + "Grant", + "Hadley Rille", + "Heat Shield Rock","Hoba", + "Homestead", + "Hraschina", + "Huckitta", + "Imilac", + "Itqiy", + "Kaidun","Kainsaz", + "Karoonda", + "Kesen", + "Krasnojarsk", + "LAigle", + "Lac Dodon", + "Lake Murray", + "Loreto", + "Los Angeles", + "Łowicz", + "Mackinac Island", + "Mbozi","Middlesbrough", + "Millbillillie", + "Mineo", + "Monte Milone", + "Moss","Mundrabilla", + "Muonionalusta", + "Murchison", + "Nakhla", + "Nantan","Neuschwanstein", + "Northwest Africa 7034", + "Northwest Africa 7325", + "Norton County", + "Novato", + "Northwest Africa 3009", + "Oileán Ruaidh (Martian)", + "Old Woman", + "Oldenburg", + "Omolon", + "Orgueil", + "Ornans", + "Osseo", + "Österplana 065","Ourique", + "Pallasovka", + "Paragould", + "Park Forest", + "Pavlovka", + "Peace River","Peekskill", + "Penouille", + "Polonnaruwa", + "High Possil", + "Příbram", + "Pultusk","Qidong", + "Richardton", + "Santa Vitoria do Palmar", + "Sayh al Uhaymir 169","Seymchan", + "Shelter Island", + "Shergotty", + "Sikhote-Alin", + "Sołtmany","Springwater", + "St-Robert", + "Stannern", + "Sulagiri", + "Sutter's Mill","Sylacauga", + "Tagish Lake", + "Tamdakht", + "Tenham", + "Texas Fireball", + "Tissint","Tlacotepec", + "Toluca", + "Treysa", + "Twannberg", + "Veliky Ustyug", + "Vermillion","Weston", + "Willamette", + "Winona", + "Wold Cottage", + "Yamato 000593","Yamato 691","Yamato 791197", + "Yardymly", + "Zagami", + "Zaisho", + "Zaklodzie" + }; + + public static readonly IEnumerable LaunchVehicles = new[] + { + "Antares", + "Ariane 5", + "Atlas", + "Diamant", + "Dnepr", + "Delta", + "Electron", + "Energia", + "Europa", + "Falcon 9", + "Falcon Heavy", + "GSLV", + "Juno", + "Long March", + "Mercury-Redstone", + "Minotaur", + "Pegasus", + "Proton", + "PSLV", + "Safir", + "Shavit", + "Saturn IV", + "Semiorka", + "Soyouz", + "Titan", + "Vega", + "Veronique", + "Zenit" + }; + } +} diff --git a/src/FakerDotNet/Faker.cs b/src/FakerDotNet/Faker.cs index ff01837..cc8761d 100644 --- a/src/FakerDotNet/Faker.cs +++ b/src/FakerDotNet/Faker.cs @@ -42,6 +42,7 @@ public static class Faker public static IRickAndMortyFaker RickAndMorty { get; } = Container.RickAndMorty; public static IRockBandFaker RockBand { get; } = Container.RockBand; public static ISlackEmojiFaker SlackEmoji { get; } = Container.SlackEmoji; + public static ISpaceFaker Space { get; } = Container.Space; public static IStarWarsFaker StarWars { get; } = Container.StarWars; public static ISuperheroFaker Superhero { get; } = Container.Superhero; public static ITeamFaker Team { get; } = Container.Team; diff --git a/src/FakerDotNet/FakerContainer.cs b/src/FakerDotNet/FakerContainer.cs index 5df3b96..4368984 100644 --- a/src/FakerDotNet/FakerContainer.cs +++ b/src/FakerDotNet/FakerContainer.cs @@ -40,6 +40,7 @@ internal interface IFakerContainer IRickAndMortyFaker RickAndMorty { get; } IRockBandFaker RockBand { get; } ISlackEmojiFaker SlackEmoji { get; } + ISpaceFaker Space { get; } IStarWarsFaker StarWars { get; } ISuperheroFaker Superhero { get; } ITeamFaker Team { get; } @@ -90,6 +91,7 @@ public FakerContainer() RickAndMorty = new RickAndMortyFaker(this); RockBand = new RockBandFaker(this); SlackEmoji = new SlackEmojiFaker(this); + Space = new SpaceFaker(this); StarWars = new StarWarsFaker(this); Superhero = new SuperheroFaker(this); Team = new TeamFaker(this); @@ -136,6 +138,7 @@ public FakerContainer() public IRickAndMortyFaker RickAndMorty { get; } public IRockBandFaker RockBand { get; } public ISlackEmojiFaker SlackEmoji { get; } + public ISpaceFaker Space { get; } public IStarWarsFaker StarWars { get; } public ISuperheroFaker Superhero { get; } public ITeamFaker Team { get; } diff --git a/src/FakerDotNet/Fakers/SpaceFaker.cs b/src/FakerDotNet/Fakers/SpaceFaker.cs new file mode 100644 index 0000000..46c2863 --- /dev/null +++ b/src/FakerDotNet/Fakers/SpaceFaker.cs @@ -0,0 +1,104 @@ +using FakerDotNet.Data; + +namespace FakerDotNet.Fakers +{ + public interface ISpaceFaker + { + string Planet(); + string Moon(); + string Galaxy(); + string Nebula(); + string StarCluster(); + string Constellation(); + string Star(); + string Agency(); + string AgencyAbv(); + string NasaSpaceCraft(); + string Company(); + string DistanceMeasurement(); + string Meteorite(); + string LaunchVehicle(); + } + + internal class SpaceFaker : ISpaceFaker + { + private readonly IFakerContainer _fakerContainer; + + public SpaceFaker(IFakerContainer fakerContainer) + { + _fakerContainer = fakerContainer; + } + + public string Planet() + { + return _fakerContainer.Random.Element(SpaceData.Planets); + } + + public string Moon() + { + return _fakerContainer.Random.Element(SpaceData.Moons); + } + + public string Galaxy() + { + return _fakerContainer.Random.Element(SpaceData.Galaxies); + } + + public string Nebula() + { + return _fakerContainer.Random.Element(SpaceData.Nebulas); + } + + public string StarCluster() + { + return _fakerContainer.Random.Element(SpaceData.StarClusters); + } + + public string Constellation() + { + return _fakerContainer.Random.Element(SpaceData.Constellations); + } + + public string Star() + { + return _fakerContainer.Random.Element(SpaceData.Stars); + } + + public string Agency() + { + return _fakerContainer.Random.Element(SpaceData.Agencies); + } + + public string AgencyAbv() + { + return _fakerContainer.Random.Element(SpaceData.AgencyAbvs); + } + + public string NasaSpaceCraft() + { + return _fakerContainer.Random.Element(SpaceData.NasaSpaceCraft); + } + + public string Company() + { + return _fakerContainer.Random.Element(SpaceData.Companies); + } + + public string DistanceMeasurement() + { + return string.Join(" ", + _fakerContainer.Number.Number(2), + _fakerContainer.Random.Element(SpaceData.DistanceMeasurements)); + } + + public string Meteorite() + { + return _fakerContainer.Random.Element(SpaceData.Meteorites); + } + + public string LaunchVehicle() + { + return _fakerContainer.Random.Element(SpaceData.LaunchVehicles); + } + } +} diff --git a/tests/FakerDotNet.Tests/FakerContainerTests.cs b/tests/FakerDotNet.Tests/FakerContainerTests.cs index e34404a..629f417 100644 --- a/tests/FakerDotNet.Tests/FakerContainerTests.cs +++ b/tests/FakerDotNet.Tests/FakerContainerTests.cs @@ -231,6 +231,12 @@ public void SlackEmoji_returns_ISlackEmoji() Assert.IsInstanceOf(_fakerContainer.SlackEmoji); } + [Test] + public void Space_returns_ISpaceFaker() + { + Assert.IsInstanceOf(_fakerContainer.Space); + } + [Test] public void StarWars_returns_IStarWarsFaker() { diff --git a/tests/FakerDotNet.Tests/FakerTests.cs b/tests/FakerDotNet.Tests/FakerTests.cs index 0837bad..74fa068 100644 --- a/tests/FakerDotNet.Tests/FakerTests.cs +++ b/tests/FakerDotNet.Tests/FakerTests.cs @@ -223,6 +223,12 @@ public void SlackEmoji_returns_ISlackEmoji() Assert.IsInstanceOf(Faker.SlackEmoji); } + [Test] + public void Space_returns_ISpaceFaker() + { + Assert.IsInstanceOf(Faker.Space); + } + [Test] public void StarWars_returns_IStarWarsFaker() { diff --git a/tests/FakerDotNet.Tests/Fakers/RandomFakerTests.cs b/tests/FakerDotNet.Tests/Fakers/RandomFakerTests.cs index fb32b44..b8a5707 100644 --- a/tests/FakerDotNet.Tests/Fakers/RandomFakerTests.cs +++ b/tests/FakerDotNet.Tests/Fakers/RandomFakerTests.cs @@ -1,65 +1,65 @@ -using System.Linq; -using FakerDotNet.Fakers; -using NUnit.Framework; - -namespace FakerDotNet.Tests.Fakers -{ - [TestFixture] - [Parallelizable] - public class RandomFakerTests - { - [SetUp] - public void SetUp() - { - _randomFaker = new RandomFaker(); - } - - private IRandomFaker _randomFaker; - - [Test] - public void Element_returns_one_of_the_elements() - { - var collection = new[] {1, 2, 3, 4, 5}; - - Assert.Contains(_randomFaker.Element(collection), collection); - } - - [Test] - public void Element_with_empty_collection_returns_default_for_type() - { - Assert.AreEqual(0, _randomFaker.Element(Enumerable.Empty())); - Assert.AreEqual(0, _randomFaker.Element(Enumerable.Empty())); - Assert.AreEqual(null, _randomFaker.Element(Enumerable.Empty())); - Assert.AreEqual(null, _randomFaker.Element(Enumerable.Empty())); - } - - [Test] - public void Element_with_string_returns_a_single_character() - { - const string word = "Typewriter"; - - Assert.Contains(_randomFaker.Element(word), word.ToCharArray()); - } - - [Test] - public void Assortment_returns_shuffled_collection() - { - var collection = new[] {1, 2, 3, 4, 5}; - - var result = _randomFaker.Assortment(collection, 5).ToArray(); - - Assert.AreEqual(5, result.Length); - CollectionAssert.AreNotEqual(collection, result); - } - - [Test] - public void Assortment_returns_repeated_shuffled_collection_if_count_is_greater_than_length_of_collection() - { - var collection = new[] {1, 2, 3, 4, 5}; - - var result = _randomFaker.Assortment(collection, 12).ToArray(); - - Assert.AreEqual(12, result.Length); - } - } -} +using System.Linq; +using FakerDotNet.Fakers; +using NUnit.Framework; + +namespace FakerDotNet.Tests.Fakers +{ + [TestFixture] + [Parallelizable] + public class RandomFakerTests + { + [SetUp] + public void SetUp() + { + _randomFaker = new RandomFaker(); + } + + private IRandomFaker _randomFaker; + + [Test] + public void Element_returns_one_of_the_elements() + { + var collection = new[] {1, 2, 3, 4, 5}; + + Assert.Contains(_randomFaker.Element(collection), collection); + } + + [Test] + public void Element_with_empty_collection_returns_default_for_type() + { + Assert.AreEqual(0, _randomFaker.Element(Enumerable.Empty())); + Assert.AreEqual(0, _randomFaker.Element(Enumerable.Empty())); + Assert.AreEqual(null, _randomFaker.Element(Enumerable.Empty())); + Assert.AreEqual(null, _randomFaker.Element(Enumerable.Empty())); + } + + [Test] + public void Element_with_string_returns_a_single_character() + { + const string word = "Typewriter"; + + Assert.Contains(_randomFaker.Element(word), word.ToCharArray()); + } + + [Test] + public void Assortment_returns_shuffled_collection() + { + var collection = new[] {1, 2, 3, 4, 5}; + + var result = _randomFaker.Assortment(collection, 5).ToArray(); + + Assert.AreEqual(5, result.Length); + CollectionAssert.AreNotEqual(collection, result); + } + + [Test] + public void Assortment_returns_repeated_shuffled_collection_if_count_is_greater_than_length_of_collection() + { + var collection = new[] {1, 2, 3, 4, 5}; + + var result = _randomFaker.Assortment(collection, 12).ToArray(); + + Assert.AreEqual(12, result.Length); + } + } +} diff --git a/tests/FakerDotNet.Tests/Fakers/SpaceFakerTests.cs b/tests/FakerDotNet.Tests/Fakers/SpaceFakerTests.cs new file mode 100644 index 0000000..8567bdc --- /dev/null +++ b/tests/FakerDotNet.Tests/Fakers/SpaceFakerTests.cs @@ -0,0 +1,153 @@ +using FakeItEasy; +using FakerDotNet.Data; +using FakerDotNet.Fakers; +using FakerDotNet.Tests.Helpers; +using NUnit.Framework; +using System.Linq; +using System.Text.RegularExpressions; + +namespace FakerDotNet.Tests.Fakers +{ + [TestFixture] + [Parallelizable] + public class SpaceFakerTests + { + [SetUp] + public void SetUp() + { + _fakerContainer = A.Fake(); + _spaceFaker = new SpaceFaker(_fakerContainer); + } + + private IFakerContainer _fakerContainer; + private ISpaceFaker _spaceFaker; + + [Test] + public void Planet_returns_a_planet() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Planets)) + .Returns("Venus"); + + Assert.AreEqual("Venus", _spaceFaker.Planet()); + } + + [Test] + public void Moon_returns_a_moon() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Moons)) + .Returns("Europa"); + + Assert.AreEqual("Europa", _spaceFaker.Moon()); + } + + [Test] + public void Galaxy_returns_a_galaxy() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Galaxies)) + .Returns("Andromeda"); + + Assert.AreEqual("Andromeda", _spaceFaker.Galaxy()); + } + + [Test] + public void Nebula_returns_a_nebula() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Nebulas)) + .Returns("Triffid Nebula"); + + Assert.AreEqual("Triffid Nebula", _spaceFaker.Nebula()); + } + + [Test] + public void StarCluster_returns_a_star_cluster() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.StarClusters)) + .Returns("Messier 70"); + + Assert.AreEqual("Messier 70", _spaceFaker.StarCluster()); + } + + [Test] + public void Constellation_returns_a_constellation() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Constellations)) + .Returns("Orion"); + + Assert.AreEqual("Orion", _spaceFaker.Constellation()); + } + + [Test] + public void Star_returns_a_star() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Stars)) + .Returns("Proxima Centauri"); + + Assert.AreEqual("Proxima Centauri", _spaceFaker.Star()); + } + + [Test] + public void Agency_returns_an_agency() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Agencies)) + .Returns("Japan Aerospace Exploration Agency"); + + Assert.AreEqual("Japan Aerospace Exploration Agency", _spaceFaker.Agency()); + } + + [Test] + public void AgencyAbv_returns_an_agency_abbreviation() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.AgencyAbvs)) + .Returns("NASA"); + + Assert.AreEqual("NASA", _spaceFaker.AgencyAbv()); + } + + [Test] + public void NasaSpaceCraft_returns_a_nasa_spacecraft() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.NasaSpaceCraft)) + .Returns("Endeavour"); + + Assert.AreEqual("Endeavour", _spaceFaker.NasaSpaceCraft()); + } + + [Test] + public void Company_returns_a_company() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Companies)) + .Returns("SpaceX"); + + Assert.AreEqual("SpaceX", _spaceFaker.Company()); + } + + [Test] + public void DistanceMeasurement_returns_a_distance_measurement_with_two_digit_number() + { + A.CallTo(() => _fakerContainer.Number.Number(2)) + .Returns("15"); + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.DistanceMeasurements)) + .Returns("parsecs"); + + Assert.AreEqual($"15 parsecs", _spaceFaker.DistanceMeasurement()); + } + + [Test] + public void Meteorite_returns_a_meteorite() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.Meteorites)) + .Returns("Ensisheim"); + + Assert.AreEqual("Ensisheim", _spaceFaker.Meteorite()); + } + + [Test] + public void LaunchVehicle_returns_a_launch_vehicle() + { + A.CallTo(() => _fakerContainer.Random.Element(SpaceData.LaunchVehicles)) + .Returns("Saturn IV"); + + Assert.AreEqual("Saturn IV", _spaceFaker.LaunchVehicle()); + } + } +} diff --git a/tests/FakerDotNet.Tests/Fakers/VehicleFakerTests.cs b/tests/FakerDotNet.Tests/Fakers/VehicleFakerTests.cs index 56a822d..dd95176 100644 --- a/tests/FakerDotNet.Tests/Fakers/VehicleFakerTests.cs +++ b/tests/FakerDotNet.Tests/Fakers/VehicleFakerTests.cs @@ -1,296 +1,296 @@ -using FakeItEasy; -using FakerDotNet.Fakers; -using FakerDotNet.Wrappers; -using NUnit.Framework; -using System; -using System.Linq; -using System.Text.RegularExpressions; -using FakerDotNet.Data; - -namespace FakerDotNet.Tests.Fakers -{ - [TestFixture] - [Parallelizable] - public class VehicleFakerTests - { - [SetUp] - public void SetUp() - { - _fakerContainer = A.Fake(); - _randomWrapper = A.Fake(); - _vehicleFaker = new VehicleFaker(_fakerContainer, _randomWrapper); - } - - private IFakerContainer _fakerContainer; - private IVehicleFaker _vehicleFaker; - private IRandomWrapper _randomWrapper; - - [Test] - public void Make_returns_a_make() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) - .Returns("Honda"); - - Assert.AreEqual("Honda", _vehicleFaker.Make()); - } - - [Test] - public void Manufacture_returns_a_manufacture() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Manufactures)) - .Returns("Lamborghini"); - - Assert.AreEqual("Lamborghini", _vehicleFaker.Manufacture()); - } - - [Test] - public void Vin_returns_a_valid_vin() - { - var fakerContainer = new FakerContainer(); - var vin = fakerContainer.Vehicle.Vin(); - - Assert.AreEqual(17, vin.Length); - Assert.False(vin.Any(c => c == 'I' || c == 'Q' || c == 'O')); - Assert.IsTrue(Regex.Match(vin, @"^[A-Z0-9]{8}[X0-9][A-Z0-9]{8}", RegexOptions.IgnoreCase).Success, $"Vin was: {vin}"); - } - - [Test] - public void Model_returns_a_model() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) - .Returns("Audi"); - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Audi"])) - .Returns("A8"); - - Assert.AreEqual("A8", _vehicleFaker.Model()); - } - - [Test] - public void Model_returns_a_model_for_make() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Toyota"])) - .Returns("Prius"); - - Assert.AreEqual("Prius", _vehicleFaker.Model("Toyota")); - } - - [Test] - public void MakeAndModel_returns_a_make_and_model() { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) - .Returns("Dodge"); - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Dodge"])) - .Returns("Charger"); - - Assert.AreEqual("Dodge Charger", _vehicleFaker.MakeAndModel()); - } - - [Test] - public void Color_returns_a_color() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Colors)) - .Returns("Red"); - - Assert.AreEqual("Red", _vehicleFaker.Color()); - } - - [Test] - public void Transmission_returns_a_transmission() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Transmissions)) - .Returns("Automanual"); - - Assert.AreEqual("Automanual", _vehicleFaker.Transmission()); - } - - [Test] - public void DriveType_returns_a_drive_type() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.DriveTypes)) - .Returns("4x2/2-wheel drive"); - - Assert.AreEqual("4x2/2-wheel drive", _vehicleFaker.DriveType()); - } - - [Test] - public void FuelType_returns_a_fuel_type() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.FuelTypes)) - .Returns("Diesel"); - - Assert.AreEqual("Diesel", _vehicleFaker.FuelType()); - } - - [Test] - public void VehicleStyles_returns_a_vehicle_style() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.VehicleStyles)) - .Returns("ESi"); - - Assert.AreEqual("ESi", _vehicleFaker.VehicleStyle()); - } - - [Test] - public void CarTypes_returns_a_car_type() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.CarTypes)) - .Returns("Sedan"); - - Assert.AreEqual("Sedan", _vehicleFaker.CarType()); - } - - - [Test] - public void CarOptions_returns_some_car_options() - { - var carOptions = new[] - { - "DVD System", - "MP3 (Single Disc)", - "Tow Package", - "CD (Multi Disc)", - "Cassette Player", - "Bucket Seats", - "Cassette Player", - "Leather Interior", - "AM/FM Stereo", - "Third Row Seats" - }; - - A.CallTo(() => _randomWrapper.Next(5, 10)) - .Returns(10); - A.CallTo(() => _fakerContainer.Random.Assortment(VehicleData.CarOptions, 10)) - .Returns(carOptions); - - Assert.AreEqual(carOptions, _vehicleFaker.CarOptions()); - } - - [Test] - public void StandardSpecs_returns_some_standard_specs() - { - var standardSpecs = new[] - { - "Full-size spare tire w/aluminum alloy wheel", - "Back-up camera", - "Carpeted cargo area", - "Silver accent IP trim finisher -inc: silver shifter finisher", - "Back-up camera", - "Water-repellent windshield & front door glass", - "Floor carpeting" - }; - - A.CallTo(() => _randomWrapper.Next(5, 10)) - .Returns(8); - A.CallTo(() => _fakerContainer.Random.Assortment(VehicleData.StandardSpecs, 8)) - .Returns(standardSpecs); - - Assert.AreEqual(standardSpecs, _vehicleFaker.StandardSpecs()); - } - - [Test] - public void Doors_returns_a_door() - { - A.CallTo(() => _randomWrapper.Next(1, 4)) - .Returns(1); - - Assert.AreEqual(1, _vehicleFaker.Doors()); - } - - [Test] - public void DoorCount_returns_a_door_count() - { - A.CallTo(() => _randomWrapper.Next(1, 4)) - .Returns(3); - - Assert.AreEqual(3, _vehicleFaker.DoorCount()); - } - - [Test] - public void EngineSize_returns_an_engine_size() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.EngineSize)) - .Returns(6); - - Assert.AreEqual(6, _vehicleFaker.EngineSize()); - } - - [Test] - public void Engine_returns_an_engine() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.EngineSize)) - .Returns(4); - - Assert.AreEqual(4, _vehicleFaker.Engine()); - } - - [Test] - public void Year_returns_a_year() - { - A.CallTo(() => _randomWrapper.Next(365, 5475)) - .Returns(3650); - A.CallTo(() => _fakerContainer.Time.Backward(3650, TimePeriod.All)) - .Returns(DateTime.Now.AddYears(-10)); - - Assert.AreEqual(DateTime.Now.AddYears(-10).Year, _vehicleFaker.Year()); - } - - [Test] - public void Mileage_returns_mileage_defaults() - { - A.CallTo(() => _randomWrapper.Next(10000, 90000)) - .Returns(26961); - - Assert.AreEqual(26961, _vehicleFaker.Mileage()); - } - - [Test] - public void Mileage_returns_mileage_min_specified() - { - A.CallTo(() => _randomWrapper.Next(50000, 90000)) - .Returns(81557); - - Assert.AreEqual(81557, _vehicleFaker.Mileage(50000)); - } - - [Test] - public void Mileage_returns_mileage_min_and_max_specified() - { - A.CallTo(() => _randomWrapper.Next(50000, 250000)) - .Returns(117503); - - Assert.AreEqual(117503, _vehicleFaker.Mileage(50000, 250000)); - } - - [Test] - public void Kilometer_calls_mileage() - { - A.CallTo(() => _randomWrapper.Next(10000, 90000)) - .Returns(35378); - - Assert.AreEqual(35378, _vehicleFaker.Kilometers()); - } - - [Test] - public void LicensePlate_returns_plate_no_state() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateAlphabet)) - .Returns('A'); - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateNumbers)) - .Returns(1); - - Assert.AreEqual("AAA-1111", _vehicleFaker.LicensePlate()); - } - - [Test] - public void LicensePlate_returns_plate_Florida_state() - { - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateTemplateByState["FL"])) - .Returns("??? ?##"); - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateAlphabet)) - .Returns('T'); - A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateNumbers)) - .Returns(5); - - Assert.AreEqual("TTT T55", _vehicleFaker.LicensePlate("FL")); - } - } -} +using FakeItEasy; +using FakerDotNet.Fakers; +using FakerDotNet.Wrappers; +using NUnit.Framework; +using System; +using System.Linq; +using System.Text.RegularExpressions; +using FakerDotNet.Data; + +namespace FakerDotNet.Tests.Fakers +{ + [TestFixture] + [Parallelizable] + public class VehicleFakerTests + { + [SetUp] + public void SetUp() + { + _fakerContainer = A.Fake(); + _randomWrapper = A.Fake(); + _vehicleFaker = new VehicleFaker(_fakerContainer, _randomWrapper); + } + + private IFakerContainer _fakerContainer; + private IVehicleFaker _vehicleFaker; + private IRandomWrapper _randomWrapper; + + [Test] + public void Make_returns_a_make() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) + .Returns("Honda"); + + Assert.AreEqual("Honda", _vehicleFaker.Make()); + } + + [Test] + public void Manufacture_returns_a_manufacture() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Manufactures)) + .Returns("Lamborghini"); + + Assert.AreEqual("Lamborghini", _vehicleFaker.Manufacture()); + } + + [Test] + public void Vin_returns_a_valid_vin() + { + var fakerContainer = new FakerContainer(); + var vin = fakerContainer.Vehicle.Vin(); + + Assert.AreEqual(17, vin.Length); + Assert.False(vin.Any(c => c == 'I' || c == 'Q' || c == 'O')); + Assert.IsTrue(Regex.Match(vin, @"^[A-Z0-9]{8}[X0-9][A-Z0-9]{8}", RegexOptions.IgnoreCase).Success, $"Vin was: {vin}"); + } + + [Test] + public void Model_returns_a_model() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) + .Returns("Audi"); + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Audi"])) + .Returns("A8"); + + Assert.AreEqual("A8", _vehicleFaker.Model()); + } + + [Test] + public void Model_returns_a_model_for_make() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Toyota"])) + .Returns("Prius"); + + Assert.AreEqual("Prius", _vehicleFaker.Model("Toyota")); + } + + [Test] + public void MakeAndModel_returns_a_make_and_model() { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Makes)) + .Returns("Dodge"); + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.MakeModels["Dodge"])) + .Returns("Charger"); + + Assert.AreEqual("Dodge Charger", _vehicleFaker.MakeAndModel()); + } + + [Test] + public void Color_returns_a_color() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Colors)) + .Returns("Red"); + + Assert.AreEqual("Red", _vehicleFaker.Color()); + } + + [Test] + public void Transmission_returns_a_transmission() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.Transmissions)) + .Returns("Automanual"); + + Assert.AreEqual("Automanual", _vehicleFaker.Transmission()); + } + + [Test] + public void DriveType_returns_a_drive_type() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.DriveTypes)) + .Returns("4x2/2-wheel drive"); + + Assert.AreEqual("4x2/2-wheel drive", _vehicleFaker.DriveType()); + } + + [Test] + public void FuelType_returns_a_fuel_type() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.FuelTypes)) + .Returns("Diesel"); + + Assert.AreEqual("Diesel", _vehicleFaker.FuelType()); + } + + [Test] + public void VehicleStyles_returns_a_vehicle_style() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.VehicleStyles)) + .Returns("ESi"); + + Assert.AreEqual("ESi", _vehicleFaker.VehicleStyle()); + } + + [Test] + public void CarTypes_returns_a_car_type() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.CarTypes)) + .Returns("Sedan"); + + Assert.AreEqual("Sedan", _vehicleFaker.CarType()); + } + + + [Test] + public void CarOptions_returns_some_car_options() + { + var carOptions = new[] + { + "DVD System", + "MP3 (Single Disc)", + "Tow Package", + "CD (Multi Disc)", + "Cassette Player", + "Bucket Seats", + "Cassette Player", + "Leather Interior", + "AM/FM Stereo", + "Third Row Seats" + }; + + A.CallTo(() => _randomWrapper.Next(5, 10)) + .Returns(10); + A.CallTo(() => _fakerContainer.Random.Assortment(VehicleData.CarOptions, 10)) + .Returns(carOptions); + + Assert.AreEqual(carOptions, _vehicleFaker.CarOptions()); + } + + [Test] + public void StandardSpecs_returns_some_standard_specs() + { + var standardSpecs = new[] + { + "Full-size spare tire w/aluminum alloy wheel", + "Back-up camera", + "Carpeted cargo area", + "Silver accent IP trim finisher -inc: silver shifter finisher", + "Back-up camera", + "Water-repellent windshield & front door glass", + "Floor carpeting" + }; + + A.CallTo(() => _randomWrapper.Next(5, 10)) + .Returns(8); + A.CallTo(() => _fakerContainer.Random.Assortment(VehicleData.StandardSpecs, 8)) + .Returns(standardSpecs); + + Assert.AreEqual(standardSpecs, _vehicleFaker.StandardSpecs()); + } + + [Test] + public void Doors_returns_a_door() + { + A.CallTo(() => _randomWrapper.Next(1, 4)) + .Returns(1); + + Assert.AreEqual(1, _vehicleFaker.Doors()); + } + + [Test] + public void DoorCount_returns_a_door_count() + { + A.CallTo(() => _randomWrapper.Next(1, 4)) + .Returns(3); + + Assert.AreEqual(3, _vehicleFaker.DoorCount()); + } + + [Test] + public void EngineSize_returns_an_engine_size() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.EngineSize)) + .Returns(6); + + Assert.AreEqual(6, _vehicleFaker.EngineSize()); + } + + [Test] + public void Engine_returns_an_engine() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.EngineSize)) + .Returns(4); + + Assert.AreEqual(4, _vehicleFaker.Engine()); + } + + [Test] + public void Year_returns_a_year() + { + A.CallTo(() => _randomWrapper.Next(365, 5475)) + .Returns(3650); + A.CallTo(() => _fakerContainer.Time.Backward(3650, TimePeriod.All)) + .Returns(DateTime.Now.AddYears(-10)); + + Assert.AreEqual(DateTime.Now.AddYears(-10).Year, _vehicleFaker.Year()); + } + + [Test] + public void Mileage_returns_mileage_defaults() + { + A.CallTo(() => _randomWrapper.Next(10000, 90000)) + .Returns(26961); + + Assert.AreEqual(26961, _vehicleFaker.Mileage()); + } + + [Test] + public void Mileage_returns_mileage_min_specified() + { + A.CallTo(() => _randomWrapper.Next(50000, 90000)) + .Returns(81557); + + Assert.AreEqual(81557, _vehicleFaker.Mileage(50000)); + } + + [Test] + public void Mileage_returns_mileage_min_and_max_specified() + { + A.CallTo(() => _randomWrapper.Next(50000, 250000)) + .Returns(117503); + + Assert.AreEqual(117503, _vehicleFaker.Mileage(50000, 250000)); + } + + [Test] + public void Kilometer_calls_mileage() + { + A.CallTo(() => _randomWrapper.Next(10000, 90000)) + .Returns(35378); + + Assert.AreEqual(35378, _vehicleFaker.Kilometers()); + } + + [Test] + public void LicensePlate_returns_plate_no_state() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateAlphabet)) + .Returns('A'); + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateNumbers)) + .Returns(1); + + Assert.AreEqual("AAA-1111", _vehicleFaker.LicensePlate()); + } + + [Test] + public void LicensePlate_returns_plate_Florida_state() + { + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateTemplateByState["FL"])) + .Returns("??? ?##"); + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateAlphabet)) + .Returns('T'); + A.CallTo(() => _fakerContainer.Random.Element(VehicleData.LicensePlateNumbers)) + .Returns(5); + + Assert.AreEqual("TTT T55", _vehicleFaker.LicensePlate("FL")); + } + } +}