TestDataFramework.dll 3.5.1

Unit test data population tool.

Install-Package TestDataFramework.dll -Version 3.5.1
dotnet add package TestDataFramework.dll --version 3.5.1
<PackageReference Include="TestDataFramework.dll" Version="3.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TestDataFramework.dll --version 3.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TestDataFramework.dll, 3.5.1"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

This is a unit testing tool. It randomizes values in your classes automatically so you don't need to do data entry.

This tool includes the optional ability to write out objects to a database for tests which involve data access.

To get an object value quickly:

    IPopulator memoryPopulator = StaticPopulatorFactory.CreateMemoryPopulator();

    SubjectClass subject = memoryPopulator.Make<SubjectClass>();

    // Or

    // Makes five objects
    IEnumerable<SubjectClass> subjectSet = memoryPopulator.Make<SubjectClass>(5);

The above example uses the in-memory populator.

Defer population of the database with the Bind method.

DON'T use the Make() or MakeAndBind() methods with the SQL Server populator unless you know what you are doing. They will write to the database immediately.

Example:

    IPopulator populator = this.factory.CreateSqlClientPopulator(
        @"Data Source=localhost;Initial Catalog=TestDataFramework;Integrated Security=SSPI;",
        mustBeInATransaction: false);

    RecordReference<SqlSubjectClass> result = populator.Add<SqlSubjectClass>().Set(p => p.Text, "ABCD");
    populator.Bind();

    // DB record that is represented by SqlSubjectClass is now populated. 
    // Get a copy of the values written out by accessing the RecordReference:
    
    SqlSubjectClass subject = result.RecordObject;

The Bind method is available on the IPopulator for in-memory only value generation also.

Go to the Wiki for more.

This is a unit testing tool. It randomizes values in your classes automatically so you don't need to do data entry.

This tool includes the optional ability to write out objects to a database for tests which involve data access.

To get an object value quickly:

    IPopulator memoryPopulator = StaticPopulatorFactory.CreateMemoryPopulator();

    SubjectClass subject = memoryPopulator.Make<SubjectClass>();

    // Or

    // Makes five objects
    IEnumerable<SubjectClass> subjectSet = memoryPopulator.Make<SubjectClass>(5);

The above example uses the in-memory populator.

Defer population of the database with the Bind method.

DON'T use the Make() or MakeAndBind() methods with the SQL Server populator unless you know what you are doing. They will write to the database immediately.

Example:

    IPopulator populator = this.factory.CreateSqlClientPopulator(
        @"Data Source=localhost;Initial Catalog=TestDataFramework;Integrated Security=SSPI;",
        mustBeInATransaction: false);

    RecordReference<SqlSubjectClass> result = populator.Add<SqlSubjectClass>().Set(p => p.Text, "ABCD");
    populator.Bind();

    // DB record that is represented by SqlSubjectClass is now populated. 
    // Get a copy of the values written out by accessing the RecordReference:
    
    SqlSubjectClass subject = result.RecordObject;

The Bind method is available on the IPopulator for in-memory only value generation also.

Go to the Wiki for more.

Release Notes

3.5.1
   - Random instantiated in static context so multiple instances of populator in quick succession don't repeat random sequences.
   - DeleteAll() now sends all Sql commands in a single batch.
       3.5.0
           - Added a DeleteAll() method to the populator. Implemented for the Sql Populator.
             Caution: Will throw if foreign key violation because of dependencies on generated
             rows introduced by external processes.
       3.4.1
           - DateTimeOffset works with Sql Server DB populator.
       3.4.0
           - Expicit foreign key / priamry key property assignment. Useful for foreign key records
             that have multiple foreign keys pointing to different instances of the same table/type.
           - Works with DateTimeOffset
           - Can set max string length in Code Generator.
           
       3.3.5
           - Bug fix: Escaping single quote for explicitly set string property when using the Sql Server populator.
   
       3.3.4
           - Fixed: BindInATransaction method on the Memory populator now calls the existing Bind method.
           It was doing just a no op.              

       3.3.3
           - Minor breaking change:
           - 1. Transation options parameter removed from the BindInATransaction method.
           - 2. Transaction options are now set on the Sql populator interface.
           - BindInATransaction method is now available in the IPopulator base interface.
           - Memory populator implements a No Op for it.
           - The pacakge now has the correct updated library. Previous package had an older version.               
   
       3.3.2
           - Array randomizer was calling ToString on a constructed value. Could cause an exception if thrown in ToString.
           - Direct call to Make on the Populators will remove the RecordReference from being tracked before returning.
           - Ability to remove a single Populatable (Record Reference or operable list of) on the populator.
           
       3.3.1
           - Bug fix: array/enumerable directly requested from the populator via Add or Make was throwing.
           - Deferred values now work on nested properties.
           
       3.3.0
           - BindInATransaction method off of the SQL populator returning an IDisposable transaction wrapper object.
             Ie: Using a transaction scope with multuiple DBs such as for EF and TestDataFramework doesn't work in the cloud/Azure.
             This is to fix it.
           
           - Improvements to bundled TestDataCodeGenerator. Eg: Load all table names in one click.
             MaxAttribute added to numeric columns thatg can have small precision. Eg: The framework will respect maximums
             for randomized values when number of significant digits is small in floating point DB types.
       
       3.2.1
           - long integer arguments to the Min and Max attributes now work with floating point value generation.
   
       3.2
           - Added Min and Max attribute handling to all scalar and floating point type handlers.
       
       3.1.4.1 No TestDataFramework changes.  TestDataCodeGenerator.exe utility bug fix.
   
       3.1.4
           - ToString on generated objects will not be called in the log messages.
             Some ToString implementations were causing an an exception.
           
           - Catching exception on SetProperty in the property population code.
       
       3.1.3         
           - Attempting constructors from least number of parameters to greatest number of parameters.
           - Swallowing exception if one occurs during constructor invocation on a target object.
            
       3.1.2        
           - Added missing overload for GuaranteeByFixedQuantity in the derived OperableLists.
             Was missing overload taking IEnumerable<T> and an explicit fixed quantity
             
3.1.0
           - Removing state from a service. Allows the same populator object to be used in generation
 of an explicitly set property value.

3.1
- Deep setting of properties.

- Deep setting of object graph properties beyond a collection.

- Make an object in one line via Make and BindAndMake.

- Ignore a property (to avoid possible side effects).

- Exclusive range of possible values for a property.

- Take and Skip operations for control of what subsets of a collection explicit setters apply to.

- Better encapsulation. Less public/protected member exposure.
   
2.4
* Bug fixes:
Value type and enum constructor parameters were not being populated.
Unsigned integer properties were causing code to break.

2.3.1
* Bug fix. Constructor finder was finding a constructor for a string with a char array parameter.
Was trying to invoke it. Now circumventing this for value/string types and arrays.
Populating those constructor arguments directly.

2.3
* Populator will now attempt to resolve constructor with parameters.
Constructors are attempted from least number of parameters (including zero) to most number of parameters.

2.2.4.0
* Bug fix. When calling deferred value generator, was including record references that were not populatable, and therefore null.
This was causing a null reference exception when the generator tried to access a method (GetType()) off the null record.

2.2.3.4
* Ability to ignore properties. Useful to avoid side effects of properties with logic in the setter.
New RecordObjects convenience property on the OperableList<T> result collection type. Instead of
user having to write the LINQ statement to select out the RecordObjects.

2.2.3.2
* All setters on a property are executed in turn.

2.2.3.1
* Support for enums

2.2.2.0

* Bug fix. A combination of explicit/deep property setting and collections in the target object were
causing a null ref exception.

2.2.1.0

* Fixed bug in deep explicit property setting, same issue as in 2.0.4.4. It's a relatively rare edge case.
Calling Make/BindAndMake on an operable list will call the persistence layer only once for entire list.
Was calling once per element. Will save database round trips when DB populator is used.

2.2.0.0

* Deep explicit setting of properties.

2.1.0.0

* Introduction of the ability to get a value immediately by calling Make() or BindAndMake().
This is without needing to call IPopulator.Bind() separately to get values on the whole set
of requested objects.

2.0.4.4

* Bug Fix. Setting explicit value off of an interface didn't identify the concrete object's
actual (derived) type. Under these conditions, properties weren't being explicitly set
on the object instance.

2.0.4.3

* Assembly version properties correction.

2.0.4.2

* Syncing C# and Sql Server DateTime values for the Sql Server populator.
Milliseconds were being truncated on Sql Server but not in C#.

2.0.4.1

* Extra guard when accessing types from assemblies to be scanned.
Was throwing a ReflectionTypeLoadException for a particular assembly/type.

2.0.4

* Bug fix: Guid / uniqueidentifier in Sql Server now supported.

2.0.3

* Foreign keys can be explicitly set. Framework will not enforce referential integrity for those
properties if so.

Allows you to set a foreign key to null if the matching primary key table isn't in the C# model.
Referential integrity errors on the database server can occur if you introduce them this way.

* Internal methods/members of public facing types are marked as internal (or internal protected)
to reduce user's intellisense noise.

* Skipping assemblies that are not found in the file system during scannig of referenced
assemblies for primary/foreign table class matches. An exception had been occuring for some
assemblies, possibly becasue they were not in the bin folder due to being in the GAC.

* Adding an AppSettings key to explicitly enable or disable log messages. The key is:
"TestDataFramework-EnableLogger". The value to enable logging is "true".

2.0.2

Documentation is up to date on GitHub.

*  Guarantee methods work with primary keys properly.

2.0.1.

* RecordReference.Set method fix.

* Guarantee... methods fix.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.5.1 349 3/31/2019
3.5.0 288 3/3/2019
3.4.1 305 2/20/2019
3.4.0 308 2/19/2019
3.3.5 346 12/1/2018
3.3.4 357 11/26/2018
3.3.3 316 11/22/2018
3.3.2 354 11/5/2018
3.3.1 354 11/2/2018
3.3.0 335 10/29/2018
3.2.1 374 10/25/2018
3.2.0 358 10/25/2018
3.1.4 363 10/9/2018
3.1.3 378 10/9/2018
3.1.2 382 10/8/2018
3.1.1 364 9/22/2018
3.0.1 401 8/26/2018
2.4.0 707 1/22/2018
2.2.4 483 1/19/2018
2.2.3.4 573 1/12/2018
2.2.3.2 526 12/13/2017
2.2.2 579 12/9/2017
2.2.1 527 12/4/2017
2.2.0 540 11/22/2017
2.1.0 731 10/30/2017
2.0.4.4 594 7/11/2017
2.0.4.3 507 7/9/2017
2.0.4.2 481 7/9/2017
2.0.4.1 487 7/9/2017
2.0.4 533 7/6/2017
2.0.3 470 7/2/2017
2.0.2 586 1/9/2017
2.0.1 636 12/7/2016