Skip to content

Blmeyers master #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ObjectFiller.Test/RandomAccessTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ObjectFiller.Test
{
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Xunit;
using Tynamix.ObjectFiller;


public class RandomAccessTest
{
[Fact]
public void GetRandomIntOnDifferentThreadsGetsDifferentResults()
{
var numberToGenerate = 1000;
var intRange = new IntRange(1, 10);
var task1 = Task.Factory.StartNew(() =>
{
var taskResults = new List<int>();
for (int i = 0; i < numberToGenerate; ++i)
{
taskResults.Add(Randomizer<int>.Create(intRange));
}
return taskResults;
},
TaskCreationOptions.LongRunning
);
var task2 = Task.Factory.StartNew(() =>
{
var taskResults = new List<int>();
for (int i = 0; i < numberToGenerate; ++i)
{
taskResults.Add(Randomizer<int>.Create(intRange));
}
return taskResults;
},
TaskCreationOptions.LongRunning
);
var results = Task.WhenAll(task1, task2).Result;
var firstResults = results[0].Sum();
var secondResults = results[1].Sum();
Assert.NotEqual(firstResults, secondResults);
}
}
}
6 changes: 3 additions & 3 deletions ObjectFiller.Test/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"dependencies": {
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Linq": "4.0.1",
"System.Linq": "4.0.0",
"System.Linq.Expressions": "4.0.10",
"System.Runtime.Extensions": "4.0.10",
"System.Text.RegularExpressions": "4.0.10"
Expand Down Expand Up @@ -1323,7 +1323,7 @@
"dependencies": {
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Linq": "4.0.1",
"System.Linq": "4.0.0",
"System.Linq.Expressions": "4.0.10",
"System.Runtime.Extensions": "4.0.10",
"System.Text.RegularExpressions": "4.0.10"
Expand Down Expand Up @@ -2580,7 +2580,7 @@
"dependencies": {
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Linq": "4.0.1",
"System.Linq": "4.0.0",
"System.Linq.Expressions": "4.0.10",
"System.Runtime.Extensions": "4.0.10",
"System.Text.RegularExpressions": "4.0.10"
Expand Down
41 changes: 32 additions & 9 deletions ObjectFiller/Random.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,47 @@ namespace Tynamix.ObjectFiller
/// </summary>
internal static class Random
{

private static int RandomSeed;
/// <summary>
/// Initializes static members of the <see cref="Random"/> class.
/// A instance of <see cref="Random"/>
/// </summary>
[ThreadStatic]
private static readonly System.Random Rnd;
static Random()
{
RandomSeed = Environment.TickCount;
}

#if NET3X
/// <summary>
/// Initializes static members of the <see cref="Random"/> class.
/// A instance of <see cref="Random"/>
/// </summary>
static Random()
[ThreadStatic]
private static System.Random RndStorage;

private static System.Random Rnd
{
#if NETSTD
Rnd = new System.Random();
get
{
if (RndStorage == null)
{
RndStorage = new System.Random(Interlocked.Increment(ref RandomSeed));
}
return RndStorage;
}
}
#else
int seed = Environment.TickCount;
Rnd = new System.Random(Interlocked.Increment(ref seed));
#endif
private static readonly ThreadLocal<System.Random> RndStorage = new ThreadLocal<System.Random>(() =>
new System.Random(Interlocked.Increment(ref RandomSeed)));

/// <summary>
/// A instance of <see cref="Random"/>
/// </summary>
private static System.Random Rnd
{
get { return RndStorage.Value; }
}
#endif

/// <summary>
/// Returns a nonnegative number
Expand Down
8 changes: 4 additions & 4 deletions ObjectFiller/project.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"title": "Tynamix.ObjectFiller",
"version": "1.4.0",
"title": ".NET ObjectFiller - Fill .NET objects with customized random data - by Tynamix",
"version": "1.4.1",
"description": "The Tynamix ObjectFiller.NET fills the properties of your objects with random data. Use it for unittest, prototyping and whereever you need some random testdata. It has a fluent API and is highly customizable. It supports also IEnumerables and Dictionaries and constructors WITH parameters. It is also possible to fill instances and to write private properties.",
"summary": "The Tynamix ObjectFiller.NET fills the properties of your objects with customized random data. Use it for unittests, prototyping and whereever you need some random testdata.",
"authors": [ "Roman Köhler", "Hendrik L.", "Christian Harlass", "GothikX" ],
"tags": [ "objectfiller", "tynamix", "test", "testdata", "prototyp", "prototyping", "unittest", "design", "designviewmodel", "generator", "random", "data", "randomdata", "testing", "poco", "lorem", "ipsum", "fakedata", "fake", "faker" ],
"projectUrl": "http://objectfiller.net/",
"iconUrl": "https://raw.githubusercontent.com/gokTyBalD/ObjectFiller.NET/master/logo.png",
"licenseUrl": "https://github.com/Tynamix/ObjectFiller.NET/blob/master/LICENSE.txt",
"releaseNotes": "-1.4.0\r\n* Updated to .NET Core. Now you can use ObjectFiller.NET in your .NET Core (DNX) and Windows 10 (UWP) environment!\r\n* FillerSetup can now be used for dedicated properties or types\r\n* Bugfixes\r\n\r\n-1.3.9\r\n* Bug fixed when creating types with a copy constructor \r\n\r\n-1.3.8\r\n* Support for Arrays and Nullable Enumerations\r\n* Bugfixes (thx to Hendrik L.)\r\n\r\n-1.3.6\r\n* Added Randomizer<T> class to easy generate data for simple types like int, double, string\r\n* Support for complex standalone CLR types like List<T>\r\n* CityName plugin (Thx to Hendrik L.)\r\n* E-Mail-Address plugin (Thx to Hendrik L.)\r\n* StreetName plugin (Thx to Hendrik L.)\r\n* CountryName plugin\r\n* Code cleanup\r\n* Bugfixes\r\n\r\n-1.3.2\r\n* Bugfixes\r\n\r\n-1.3.1\r\n* Easier usage of static values in the \"Use\" API\r\n* Added missing type mappings\r\n* Some bugfixes and improvements\r\n\r\n-1.3.0\r\n* Circular Reference Detection (thx to GothikX)\r\n* Export the ObjectFiller setup and reuse it somewhere else\r\n* Improved LoremIpsum Plugin (thx to GothikX)\r\n* Many bugfixes and improvements\r\n\r\n-1.2.8\r\n* IgnoreAllUnknownTypes added\r\n* Usage of RandomList-Plugin improved\r\n* IntRange-Plugin handles now also nullable int!\r\n\r\n-1.2.4\r\n* Create multiple instances\r\n* Some bugfixes and improvements\r\n\r\n-1.2.3\r\n* Use enumerables to fill objects (thx to charlass)\r\n* Its now possible to fill enum properties (thx to charlass)\r\n* Implemented SequenceGenerator (thx to charlass)\r\n\r\n-1.2.1\r\n* Complete refactoring of the FluentAPI. Read the documentation on objectfiller.net for more information!\r\n* Properties with private setter are able to write.\r\n* Renamed ObjectFiller to Filler to avoid NameSpace conflicts\r\n* Order properties implemented\r\n* IntRange Plugin implemented\r\n* ...some more improvements and bugfixes\r\n\r\n-1.1.8\r\n* Bugfix in RandomizerForProperty\r\n\r\n-1.1.7\r\n* Implemented a Lorem Ipsum string plugin\r\n\r\n-1.1.6\r\n* new fantastic PatternGenerator-Plugin. Thanks to charlass for this!\r\n* Adjust namespaces from ObjectFiller to Tynamix.ObjectFiller\r\n\r\n-1.1.4\r\n* IgnoreAllOfType added.\r\n* Little changes to the main API\r\n\r\n-1.1.2\r\n* moved to github\r\n\r\n-1.1.0\r\n* Changed the fluent API to make it even easier than before to use.\r\n\r\n-1.0.22\r\n* Bugfix when handling lists\r\n\r\n-1.0.21\r\n* Constructors with parameters are now possible as long as the types of parameters are configured in the ObjectFiller.NET setup!\r\n\r\n-1.0.16\r\n* RandomListItem-Plugin\r\n\r\n-1.0.15\r\n* Major Bugfix\r\n\r\n-1.0.14\r\n* Bugfixes\r\n\r\n-1.0.12\r\n* RealNameListString Plugin\r\n* DoubleMinMax plugin\r\n\r\n-1.0.10\r\n* Its now possible to ignore properties.\r\n* Fluent API documented.\r\n* Better ExceptionMessages\r\n* Bugfixes\r\n\r\n-1.0.6\r\n* Its now possible to setup a randomizer to a specific property!\r\n\r\n-1.0.0\r\n* Initial release",
"releaseNotes": "-1.4.1\r\n* Fixing Bug with Multi Threaded Random Access (Thanks to blmeyers)\r\n\r\n-1.4.0\r\n* Updated to .NET Core. Now you can use ObjectFiller.NET in your .NET Core (DNX) and Windows 10 (UWP) environment!\r\n* FillerSetup can now be used for dedicated properties or types\r\n* Bugfixes\r\n\r\n-1.3.9\r\n* Bug fixed when creating types with a copy constructor \r\n\r\n-1.3.8\r\n* Support for Arrays and Nullable Enumerations\r\n* Bugfixes (thx to Hendrik L.)\r\n\r\n-1.3.6\r\n* Added Randomizer<T> class to easy generate data for simple types like int, double, string\r\n* Support for complex standalone CLR types like List<T>\r\n* CityName plugin (Thx to Hendrik L.)\r\n* E-Mail-Address plugin (Thx to Hendrik L.)\r\n* StreetName plugin (Thx to Hendrik L.)\r\n* CountryName plugin\r\n* Code cleanup\r\n* Bugfixes\r\n\r\n-1.3.2\r\n* Bugfixes\r\n\r\n-1.3.1\r\n* Easier usage of static values in the \"Use\" API\r\n* Added missing type mappings\r\n* Some bugfixes and improvements\r\n\r\n-1.3.0\r\n* Circular Reference Detection (thx to GothikX)\r\n* Export the ObjectFiller setup and reuse it somewhere else\r\n* Improved LoremIpsum Plugin (thx to GothikX)\r\n* Many bugfixes and improvements\r\n\r\n-1.2.8\r\n* IgnoreAllUnknownTypes added\r\n* Usage of RandomList-Plugin improved\r\n* IntRange-Plugin handles now also nullable int!\r\n\r\n-1.2.4\r\n* Create multiple instances\r\n* Some bugfixes and improvements\r\n\r\n-1.2.3\r\n* Use enumerables to fill objects (thx to charlass)\r\n* Its now possible to fill enum properties (thx to charlass)\r\n* Implemented SequenceGenerator (thx to charlass)\r\n\r\n-1.2.1\r\n* Complete refactoring of the FluentAPI. Read the documentation on objectfiller.net for more information!\r\n* Properties with private setter are able to write.\r\n* Renamed ObjectFiller to Filler to avoid NameSpace conflicts\r\n* Order properties implemented\r\n* IntRange Plugin implemented\r\n* ...some more improvements and bugfixes\r\n\r\n-1.1.8\r\n* Bugfix in RandomizerForProperty\r\n\r\n-1.1.7\r\n* Implemented a Lorem Ipsum string plugin\r\n\r\n-1.1.6\r\n* new fantastic PatternGenerator-Plugin. Thanks to charlass for this!\r\n* Adjust namespaces from ObjectFiller to Tynamix.ObjectFiller\r\n\r\n-1.1.4\r\n* IgnoreAllOfType added.\r\n* Little changes to the main API\r\n\r\n-1.1.2\r\n* moved to github\r\n\r\n-1.1.0\r\n* Changed the fluent API to make it even easier than before to use.\r\n\r\n-1.0.22\r\n* Bugfix when handling lists\r\n\r\n-1.0.21\r\n* Constructors with parameters are now possible as long as the types of parameters are configured in the ObjectFiller.NET setup!\r\n\r\n-1.0.16\r\n* RandomListItem-Plugin\r\n\r\n-1.0.15\r\n* Major Bugfix\r\n\r\n-1.0.14\r\n* Bugfixes\r\n\r\n-1.0.12\r\n* RealNameListString Plugin\r\n* DoubleMinMax plugin\r\n\r\n-1.0.10\r\n* Its now possible to ignore properties.\r\n* Fluent API documented.\r\n* Better ExceptionMessages\r\n* Bugfixes\r\n\r\n-1.0.6\r\n* Its now possible to setup a randomizer to a specific property!\r\n\r\n-1.0.0\r\n* Initial release",

"frameworks": {
"net40": {
Expand All @@ -35,7 +35,7 @@
"dependencies": {
"System.Collections": "4.0.10-*",
"System.Diagnostics.Debug": "4.0.10-*",
"System.Linq": "4.0.1-*",
"System.Linq": "4.0.0-*",
"System.Linq.Expressions": "4.0.10-*",
"System.Runtime.Extensions": "4.0.10-*",
"System.Text.RegularExpressions": "4.0.10-*"
Expand Down
86 changes: 31 additions & 55 deletions ObjectFiller/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,14 +1163,20 @@
"ref/dotnet/System.IO.dll": {}
}
},
"System.Linq/4.0.1-beta-23516": {
"System.Linq/4.0.0": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.0",
"System.Runtime": "4.0.0"
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Resources.ResourceManager": "4.0.0",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10"
},
"compile": {
"ref/dotnet5.1/System.Linq.dll": {}
"ref/dotnet/System.Linq.dll": {}
},
"runtime": {
"lib/dotnet/System.Linq.dll": {}
}
},
"System.Linq.Expressions/4.0.10": {
Expand Down Expand Up @@ -3660,14 +3666,20 @@
"ref/dotnet/System.IO.dll": {}
}
},
"System.Linq/4.0.1-beta-23516": {
"System.Linq/4.0.0": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.0",
"System.Runtime": "4.0.0"
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Resources.ResourceManager": "4.0.0",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10"
},
"compile": {
"ref/dotnet5.1/System.Linq.dll": {}
"ref/dotnet/System.Linq.dll": {}
},
"runtime": {
"lib/dotnet/System.Linq.dll": {}
}
},
"System.Linq.Expressions/4.0.10": {
Expand Down Expand Up @@ -3834,14 +3846,20 @@
"ref/dotnet/System.IO.dll": {}
}
},
"System.Linq/4.0.1-beta-23516": {
"System.Linq/4.0.0": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.0",
"System.Runtime": "4.0.0"
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Resources.ResourceManager": "4.0.0",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10"
},
"compile": {
"ref/dotnet5.1/System.Linq.dll": {}
"ref/dotnet/System.Linq.dll": {}
},
"runtime": {
"lib/dotnet/System.Linq.dll": {}
}
},
"System.Linq.Expressions/4.0.10": {
Expand Down Expand Up @@ -4899,48 +4917,6 @@
"System.Linq.nuspec"
]
},
"System.Linq/4.0.1-beta-23516": {
"type": "package",
"serviceable": true,
"sha512": "uNxm2RB+kMeiKnY26iPvOtJLzTzNaAF4A2qqyzev6j8x8w2Dr+gg7LF7BHCwC55N7OirhHrAWUb3C0n4oi9qYw==",
"files": [
"lib/dotnet5.4/System.Linq.dll",
"lib/net45/_._",
"lib/netcore50/System.Linq.dll",
"lib/win8/_._",
"lib/wp80/_._",
"lib/wpa81/_._",
"ref/dotnet5.1/de/System.Linq.xml",
"ref/dotnet5.1/es/System.Linq.xml",
"ref/dotnet5.1/fr/System.Linq.xml",
"ref/dotnet5.1/it/System.Linq.xml",
"ref/dotnet5.1/ja/System.Linq.xml",
"ref/dotnet5.1/ko/System.Linq.xml",
"ref/dotnet5.1/ru/System.Linq.xml",
"ref/dotnet5.1/System.Linq.dll",
"ref/dotnet5.1/System.Linq.xml",
"ref/dotnet5.1/zh-hans/System.Linq.xml",
"ref/dotnet5.1/zh-hant/System.Linq.xml",
"ref/net45/_._",
"ref/netcore50/de/System.Linq.xml",
"ref/netcore50/es/System.Linq.xml",
"ref/netcore50/fr/System.Linq.xml",
"ref/netcore50/it/System.Linq.xml",
"ref/netcore50/ja/System.Linq.xml",
"ref/netcore50/ko/System.Linq.xml",
"ref/netcore50/ru/System.Linq.xml",
"ref/netcore50/System.Linq.dll",
"ref/netcore50/System.Linq.xml",
"ref/netcore50/zh-hans/System.Linq.xml",
"ref/netcore50/zh-hant/System.Linq.xml",
"ref/win8/_._",
"ref/wp80/_._",
"ref/wpa81/_._",
"System.Linq.4.0.1-beta-23516.nupkg",
"System.Linq.4.0.1-beta-23516.nupkg.sha512",
"System.Linq.nuspec"
]
},
"System.Linq.Expressions/4.0.10": {
"type": "package",
"serviceable": true,
Expand Down Expand Up @@ -6307,7 +6283,7 @@
".NETPlatform,Version=v5.1": [
"System.Collections >= 4.0.10-*",
"System.Diagnostics.Debug >= 4.0.10-*",
"System.Linq >= 4.0.1-*",
"System.Linq >= 4.0.0-*",
"System.Linq.Expressions >= 4.0.10-*",
"System.Runtime.Extensions >= 4.0.10-*",
"System.Text.RegularExpressions >= 4.0.10-*"
Expand Down