Skip to content

Commit

Permalink
Merge a3d0d59 into 1159fdf
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstebo committed Oct 24, 2018
2 parents 1159fdf + a3d0d59 commit 2907e7a
Show file tree
Hide file tree
Showing 13 changed files with 1,351 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Contents
- [Faker.Book](doc/book.md)
- [Faker.Boolean](doc/boolean.md)
- [Faker.Business](doc/business.md)
- [Faker.Company](doc/company.md)
- [Faker.Date](doc/date.md)
- [Faker.Fake](doc/fake.md)
- [Faker.GameOfThrones](doc/game_of_thrones.md)
Expand Down
49 changes: 49 additions & 0 deletions doc/company.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Faker.Company

```cs
Faker.Company.Name() //=> "Hirthe-Ritchie"
Faker.Company.Suffix() //=> "Group"
Faker.Company.Industry() //=> "Information Services"
// Generate a buzzword-laden catch phrase.
Faker.Company.CatchPhrase() //=> "Business-focused coherent parallelism"
Faker.Company.Buzzword() //=> "Business-focused"
// When a straight answer won't do, BS to the rescue!
Faker.Company.Bs() //=> "empower one-to-one web-readiness"
// Generate US employee identification numbers
Faker.Company.Ein() //=> "34-8488813"
// Generate "Data Universal Numbering System"
Faker.Company.DunsNumber() //=> "08-341-3736"
// Get a random company logo url in PNG format.
Faker.Company.Logo() //=> "https://pigment.github.io/fake-logos/logos/medium/color/5.png"
Faker.Company.Type() //=> "Privately Held"
#//Get a random profession
Faker.Company.Profession() //=> "firefighter"
// Generate country specific identifiers
Faker.Company.SwedishOrganisationNumber() //=> "7962578022"
Faker.Company.CzechOrganisationNumber() //=> "77778171"
Faker.Company.FrenchSirenNumber() //=> "819489626"
Faker.Company.FrenchSiretNumber() //=> "81948962600013"
Faker.Company.SpanishOrganisationNumber() //=> "P2344979"
// Generate South African company registration numbers:
Faker.Company.SouthAfricanPtyLtdRegistrationNumber() //=> "5301/714689/07"
Faker.Company.SouthAfricanCloseCorporationRegistrationNumber() //=> "CK74/7585/23"
Faker.Company.SouthAfricanListedCompanyRegistrationNumber() //=> "7039/3135/06"
Faker.Company.SouthAfricanTrustRegistrationNumber() //=> "IT38/6489900"
```
27 changes: 27 additions & 0 deletions src/FakerDotNet/Algorithms/LuhnAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Linq;

namespace FakerDotNet.Algorithms
{
internal static class LuhnAlgorithm
{
public static int GetCheckValue(long number)
{
var sum = $"{number}"
.ToCharArray()
.Reverse()
.Select(c => int.Parse(new string(c, 1)))
.Select((x, i) => i % 2 == 0 ? x * 2 : x)
.Select(SumAllDigits)
.Sum();

return sum % 10 == 0 ? 0 : (sum / 10 + 1) * 10 - sum;
}

private static int SumAllDigits(int number)
{
return $"{number}"
.ToCharArray()
.Sum(c => int.Parse(new string(c, 1)));
}
}
}

0 comments on commit 2907e7a

Please sign in to comment.