Skip to content

Commit

Permalink
Russian locale update. Feature parity with faker.js @ https://github.…
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed Apr 24, 2017
1 parent f3a4a20 commit c88a9ea
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 36 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* Added `Address.FullAddress`
* Added `Name.Occupation` as an alternate source of job titles.
* Added `Internet.UrlWithPath` allowing to create URLs with random paths.
* Added `ru` (Russian locale) hacker adjective, ing-verb, noun, and verb.
* Added `Internet.Mac` address separator parameter.
* Feature parity with **faker.js** @ 6cdb93ef...

## v15.0.1
* Building with Visual Studio 2017.
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus.Tests/Bogus.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<Compile Include="GitHubIssues\Issue55.cs" />
<Compile Include="GitHubIssues\Issue61.cs" />
<Compile Include="GitHubIssues\Issue70.cs" />
<Compile Include="HackerFixture.cs" />
<Compile Include="HackerTests.cs" />
<Compile Include="HandleBarTests.cs" />
<Compile Include="ImageTest.cs" />
<Compile Include="InternetTests.cs" />
Expand Down
26 changes: 0 additions & 26 deletions Source/Bogus.Tests/HackerFixture.cs

This file was deleted.

36 changes: 36 additions & 0 deletions Source/Bogus.Tests/HackerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Bogus.DataSets;
using FluentAssertions;
using NUnit.Framework;

namespace Bogus.Tests
{
[TestFixture]
public class HackerTests : SeededTest
{
private Hacker hacker;


[SetUp]
public void BeforeEachTest()
{
hacker = new Hacker();
}

[Test]
public void can_get_a_hacker_phrase()
{
hacker.Phrase().Should().Be("Use the neural RAM driver, then you can calculate the neural driver!");
}

[Test]
public void make_sure_we_have_updated_ru_hacker_locale()
{
var ruhacker = new Hacker("ru");
ruhacker.Adjective().Should().Be("многобайтный");
ruhacker.Noun().Should().Be("пропускная способность");
ruhacker.Verb().Should().Be("передавать");
ruhacker.IngVerb().Should().Be("определение количества");
}

}
}
6 changes: 6 additions & 0 deletions Source/Bogus.Tests/InternetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public void can_generate_mac_address()
internet.Mac().Should().Be("9a:1c:d0:a5:09:9f");
}

[Test]
public void can_generate_mac_address_with_separator()
{
internet.Mac("_").Should().Be("9a_1c_d0_a5_09_9f");
}

[Test]
public void can_generate_an_example_email()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus.Tests/NameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void switch_locale_syntax()
[Test]
public void get_a_random_occupation()
{
name.Occupation().Should().Be("Karate Master");
name.Occupation().Should().Be("Journeyman");
}
}
}
7 changes: 7 additions & 0 deletions Source/Bogus/DataSets/Hacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace Bogus.DataSets
/// </summary>
public class Hacker : DataSet
{
/// <summary>
/// Create a hacker lingo dataset.
/// </summary>
public Hacker(string locale = "en") : base(locale)
{
}

/// <summary>
/// Returns an abbreviation.
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions Source/Bogus/DataSets/Internet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,12 @@ public string UserAgent()
/// <summary>
/// Gets a random mac address
/// </summary>
public string Mac()
public string Mac(string separator = ":")
{
var sb = new StringBuilder();

var arr = Enumerable.Range(0, 6)
.Select(s => this.Random.Number(0, 255).ToString("x2"));

return string.Join(":", arr);
return string.Join(separator, arr);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus/Faker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Faker(string locale = "en")
this.Company = new Company(locale);
this.Date = new Date {Locale = locale};
this.Finance = new Finance {Locale = locale};
this.Hacker = new Hacker();
this.Hacker = new Hacker(locale);
this.Image = new Images(locale);
this.Internet = new Internet(locale);
this.Lorem = new Lorem(locale);
Expand Down
2 changes: 0 additions & 2 deletions Source/Bogus/data/en.locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -8183,9 +8183,7 @@
"Wine Seller",
"Wrangler",
"Writer",
"Xylophonist",
"Yardman",
"Yodeler",
"Zookeeper",
"Zoologist"
]
Expand Down
86 changes: 86 additions & 0 deletions Source/Bogus/data/ru.locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,92 @@
"сб"
]
}
},
"hacker": {
"adjective": [
"вспомогательный",
"основной",
"внутренний",
"цифровой",
"open-source",
"виртуальный",
"кросс-платформенный",
"излишний",
"онлайн",
"сенсорный",
"многобайтный",
"bluetooth",
"беспроводной",
"1080p",
"нейронный",
"оптический",
"твердотельный",
"мобильный"
],
"noun": [
"драйвер",
"протокол",
"пропускная способность",
"панель",
"микрочип",
"программа",
"порт",
"карта",
"массив",
"интерфейс",
"система",
"сенсор",
"брандмауэр",
"жесткий диск",
"пиксель",
"тревога",
"устройство подачи",
"монитор",
"приложение",
"передатчик",
"материнская плата",
"схема",
"конденсатор",
"матрица"
],
"verb": [
"осуществлять резервное копирование",
"обходить",
"взломать",
"переопределить",
"сжимать",
"копировать",
"осуществлять навигацию",
"индексировать",
"соединять",
"генерировать",
"определять количество",
"вычислять",
"синтезировать",
"вводить",
"передавать",
"программировать",
"перезагружать",
"разбирать"
],
"ingverb": [
"резервное копирование",
"обход",
"взлом",
"переопределение",
"сжатие",
"копирование",
"навигация",
"индексирование",
"соединение",
"генерация",
"определение количества",
"вычисление",
"синтез",
"передача",
"программирование",
"разбор"
]
}
}
}
2 changes: 1 addition & 1 deletion Source/fakerjs

0 comments on commit c88a9ea

Please sign in to comment.