Skip to content

Commit

Permalink
Prep release, v7.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed May 15, 2016
1 parent b0a1a56 commit 0bbc082
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 7 deletions.
6 changes: 5 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## v6.1.2
## v7.1.1
* Locale update
* Date.Recent(0) generates random times for current date between midnight and now.
* New `System` data set for generating fake file names and mime-types.
* Added `Date.Timespan` for random timespan values.
* Added `System.Semver` for random semantic versions.
* Added `System.Version` for random System.Version objects.
* Added `Internet.ExampleEmail` for simple @example.com email generation.
* Added `Finance.BitcoinAddress` for random bitcoin addresses.
* BREAKING: Fake "seeded" data generated by Bogus may be different from previous versions.
* WARN: Address.City may have changed in some random seeds

## v6.1.1
* Roll-up Release for .NET Framework since last non-beta release.
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ public void Without_Fluent_Syntax()
* `StateAbbr` - Get a state abbreviation.
* `Latitude` - Get a Latitude
* `Longitude` - Get a Longitude
* **`Commerce`**
* `Department` - Get a random commerce department.
* `Price` - Get a random product price.
* `Categories` - Get random product categories
* `ProductName` - Get a random product name.
* `Color` - Get a random color.
* `Product` - Get a random product.
* `ProductAdjective` - Random product adjective.
* `ProductMaterial` - Random product material.
* **`Company`**
* `CompanySuffix` - Get a company suffix. "Inc" and "LLC" etc.
* `CompanyName` - Get a company name
Expand All @@ -237,6 +246,7 @@ public void Without_Fluent_Syntax()
* `Future` - Get a date in the future between refDate and years forward of that date.
* `Between` - Get a random date between start and end.
* `Recent` - Get a random date/time within the last few days since now.
* `Timespan` - Get a random span of time.
* `Month` - Get a random month
* `Weekday` - Get a random weekday
* **`Finance`**
Expand All @@ -246,6 +256,7 @@ public void Without_Fluent_Syntax()
* `TransactionType` - Get a transaction type: "deposit", "withdrawal", "payment", or "invoice".
* `Currency` - Get a random currency.
* `CreditCardNumber` - Returns a credit card number that should pass validation. See [here](https://developers.braintreepayments.com/ios+ruby/reference/general/testing).
* `BitcoinAddress` - Generates a random bitcoin address
* **`Hacker`**
* `Abbreviation` - Returns an abbreviation.
* `Adjective` - Returns a adjective.
Expand All @@ -271,6 +282,7 @@ public void Without_Fluent_Syntax()
* **`Internet`**
* `Avatar` - Generates a legit Internet URL avatar from twitter accounts.
* `Email` - Generates an email address.
* `ExampleEmail` - Generates an example email with @example.com
* `UserName` - Generates user names.
* `DomainName` - Generates a random domain name.
* `DomainWord` - Generates a domain word used for domain names.
Expand Down Expand Up @@ -312,6 +324,9 @@ public void Without_Fluent_Syntax()
* `CommonFileExt` - Returns a commonly used file extension
* `FileType` - Returns any file type available as mime-type
* `FileExt` - Gets a random extension for the given mime type.
* `Semver` - Get a random semver version string.
* `Version` - Get a random `System.Version`
* `Exception` - Can generate a random `Exception` with a fake stack trace.


### Helper Methods
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus.Tests/AddressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void can_get_a_county()
[Test]
public void can_get_a_country()
{
address.Country().Should().Be("Morocco");
address.Country().Should().Be("Mozambique");
}

[Test]
Expand Down
6 changes: 6 additions & 0 deletions Source/Bogus.Tests/FinanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@ public void should_be_able_to_get_a_transaction_type()
{
finance.TransactionType().Should().Be("payment");
}

[Test]
public void can_generate_a_random_bitcoin_address()
{
finance.BitcoinAddress().Dump();
}
}
}
6 changes: 6 additions & 0 deletions Source/Bogus.Tests/RandomizerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public void can_shuffle_some_enumerable()
new string(r.Shuffle("123456789").ToArray())
.Should().Be("628753491");
}

[Test]
public void can_get_random_locale()
{
r.RandomLocale().Should().Be("ru");
}
}


Expand Down
28 changes: 26 additions & 2 deletions Source/Bogus/DataSets/Commerce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public Commerce( string locale = "en" ) : base( locale )
{
}

/// <summary>
/// Get a random commerce department.
/// </summary>
public string Department(int max = 3, bool returnMax = false)
{
var num = max;
Expand All @@ -27,15 +30,21 @@ public string Department(int max = 3, bool returnMax = false)
return cats[0];
}

/// there is an easier way to do this.
/// check finance.amount
// there is an easier way to do this.
// check finance.amount
/// <summary>
/// Get a random product price.
/// </summary>
public string Price( decimal min = 0, decimal max = 1000, int decimals = 2, string symbol = "" )
{
var amount = ( max - min );
var part = (decimal)Random.Double() * amount;
return symbol + Math.Round(min + part, decimals);
}

/// <summary>
/// Get random product categories
/// </summary>
public string[] Categories(int num)
{
var result = new string[num];
Expand All @@ -47,6 +56,9 @@ public string[] Categories(int num)
return result;
}

/// <summary>
/// Get a random product name.
/// </summary>
public string ProductName()
{
return string.Format( "{0} {1} {2}",
Expand All @@ -56,21 +68,33 @@ public string ProductName()
);
}

/// <summary>
/// Get a random color.
/// </summary>
public string Color()
{
return GetRandomArrayItem( "color" );
}

/// <summary>
/// Get a random product.
/// </summary>
public string Product()
{
return GetRandomArrayItem( "product_name.product" );
}

/// <summary>
/// Random product adjective.
/// </summary>
public string ProductAdjective()
{
return GetRandomArrayItem( "product_name.adjective" );
}

/// <summary>
/// Random product material.
/// </summary>
public string ProductMaterial()
{
return GetRandomArrayItem( "product_name.material" );
Expand Down
14 changes: 14 additions & 0 deletions Source/Bogus/DataSets/Finance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ public string CreditCardNumber()

return Random.ArrayElement(cards);
}

/// <summary>
/// Generates a random bitcoin address
/// </summary>
public string BitcoinAddress()
{
var addressLength = Math.Floor(this.Random.Double()*(36 - 27 + 1)) + 27;
var address = this.Random.ArrayElement(new[] {"1", "3"});
for( var i = 0; i < addressLength - 1; i++ )
{
address += "*";
}
return Random.Replace(address);
}
}

}
4 changes: 2 additions & 2 deletions Source/Bogus/DataSets/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public string Semver()
}

/// <summary>
/// Get a random System.Version
/// Get a random `System.Version`
/// </summary>
public Version Version()
{
Expand All @@ -148,7 +148,7 @@ public Version Version()


/// <summary>
/// Can generate a random exception with a fake stack trace.
/// Can generate a random `Exception` with a fake stack trace.
/// </summary>
public Exception Exception()
{
Expand Down
11 changes: 10 additions & 1 deletion Source/Bogus/Randomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public string ReplaceNumbers(string format, char symbol = '#')
}

/// <summary>
/// Replaces symbols with numbers and letters. # = number, ? = letter, * = number or letter. IE: ###???* -> 283QED4
/// Replaces symbols with numbers and letters. # = number, ? = letter, * = number or letter. IE: ###???* -> 283QED4. Letters are uppercase.
/// </summary>
/// <param name="format"></param>
public string Replace(string format)
Expand Down Expand Up @@ -290,6 +290,15 @@ public Guid Uuid()
{
return Guid.NewGuid();
}

/// <summary>
/// Returns a random locale.
/// </summary>
public string RandomLocale()
{
var ele = ArrayElement(Database.Data.Value.Properties().ToArray()) as JProperty;
return ele.Name;
}
}

public static class WordFunctions
Expand Down

0 comments on commit 0bbc082

Please sign in to comment.