Skip to content

Commit 1bc00bd

Browse files
mwhelanrobdmoore
authored andcommitted
renamed NTestDataBuilder to TestStack.Dossier
1 parent 260c67d commit 1bc00bd

File tree

148 files changed

+283
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+283
-280
lines changed

NTestDataBuilder.Tests/packages.config

-8
This file was deleted.

README.md

+74-74
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
NTestDataBuilder
2-
================
1+
# Dossier
32

4-
NTestDataBuilder provides you with the code infrastructure to easily and quickly generate test fixture data for your automated tests in a terse, readable and maintainable way using the Test Data Builder pattern.
3+
Dossier provides you with the code infrastructure to easily and quickly generate test fixture data for your automated tests in a terse, readable and maintainable way using the Test Data Builder pattern.
54

65
For more information please see the [blog post](http://robdmoore.id.au/blog/2013/05/26/test-data-generation-the-right-way-object-mother-test-data-builders-nsubstitute-nbuilder/) that gives the theory behind the approach this library was intended for and the [presentation and example code](https://github.com/robdmoore/TestFixtureDataGenerationPresentation) that gives a concrete example of the usage of the library (and the theory behind it).
76

8-
NTestDataBuilder is integrated with NSubstitute for proxy/mock/substitute object generation and AutoFixture for anonymous value generation. Version 1 was integrated with NBuilder for list generation, but that is now replaced with internal code that uses Castle Dynamic Proxy (il-merged into the dll) for an even terser syntax.
7+
Dossier is integrated with NSubstitute for proxy/mock/substitute object generation and AutoFixture for anonymous value generation. Version 1 was integrated with NBuilder for list generation, but that is now replaced with internal code that uses Castle Dynamic Proxy (il-merged into the dll) for an even terser syntax.
98

10-
How do I get started?
11-
---------------------
9+
## How do I get started?
1210

13-
1. `Install-Package NTestDataBuilder`
14-
2. Create a builder class for one of your objects, e.g. if you have a customer:
15-
```c#
16-
// Customer.cs
17-
18-
public class Customer
19-
{
20-
protected Customer() {}
11+
1. `Install-Package TestStack.Dossier`
2112

22-
public Customer(string firstName, string lastName, int yearJoined)
23-
{
24-
if (string.IsNullOrEmpty(firstName))
25-
throw new ArgumentNullException("firstName");
26-
if (string.IsNullOrEmpty(lastName))
27-
throw new ArgumentNullException("lastName");
28-
29-
FirstName = firstName;
30-
LastName = lastName;
31-
YearJoined = yearJoined;
32-
}
33-
34-
public virtual int CustomerForHowManyYears(DateTime since)
35-
{
36-
if (since.Year < YearJoined)
37-
throw new ArgumentException("Date must be on year or after year that customer joined.", "since");
38-
return since.Year - YearJoined;
39-
}
13+
2. Create a builder class for one of your objects, e.g. if you have a customer:
4014

41-
public virtual string FirstName { get; private set; }
42-
public virtual string LastName { get; private set; }
43-
public virtual int YearJoined { get; private set; }
44-
}
45-
46-
// CustomerBuilder.cs
47-
48-
public class CustomerBuilder : TestDataBuilder<Customer, CustomerBuilder>
49-
{
50-
public CustomerBuilder()
51-
{
52-
// Can set up defaults here - any that you don't set will have an anonymous value generated by default.
53-
WhoJoinedIn(2013);
54-
}
15+
// Customer.cs
16+
17+
public class Customer
18+
{
19+
protected Customer() {}
20+
21+
public Customer(string firstName, string lastName, int yearJoined)
22+
{
23+
if (string.IsNullOrEmpty(firstName))
24+
throw new ArgumentNullException("firstName");
25+
if (string.IsNullOrEmpty(lastName))
26+
throw new ArgumentNullException("lastName");
27+
28+
FirstName = firstName;
29+
LastName = lastName;
30+
YearJoined = yearJoined;
31+
}
32+
33+
public virtual int CustomerForHowManyYears(DateTime since)
34+
{
35+
if (since.Year < YearJoined)
36+
throw new ArgumentException("Date must be on year or after year that customer joined.", "since");
37+
return since.Year - YearJoined;
38+
}
39+
40+
public virtual string FirstName { get; private set; }
41+
public virtual string LastName { get; private set; }
42+
public virtual int YearJoined { get; private set; }
43+
}
44+
45+
// CustomerBuilder.cs
46+
47+
public class CustomerBuilder : TestDataBuilder<Customer, CustomerBuilder>
48+
{
49+
public CustomerBuilder()
50+
{
51+
// Can set up defaults here - any that you don't set will have an anonymous value generated by default.
52+
WhoJoinedIn(2013);
53+
}
54+
55+
public CustomerBuilder WithFirstName(string firstName)
56+
{
57+
return Set(x => x.FirstName, firstName);
58+
}
59+
60+
public CustomerBuilder WithLastName(string lastName)
61+
{
62+
return Set(x => x.LastName, lastName);
63+
}
64+
65+
public CustomerBuilder WhoJoinedIn(int yearJoined)
66+
{
67+
return Set(x => x.YearJoined, yearJoined);
68+
}
69+
70+
protected override Customer BuildObject()
71+
{
72+
return new Customer(
73+
Get(x => x.FirstName),
74+
Get(x => x.LastName),
75+
Get(x => x.YearJoined)
76+
);
77+
}
78+
}
5579

56-
public CustomerBuilder WithFirstName(string firstName)
57-
{
58-
return Set(x => x.FirstName, firstName);
59-
}
6080

61-
public CustomerBuilder WithLastName(string lastName)
62-
{
63-
return Set(x => x.LastName, lastName);
64-
}
81+
3. Use the builder in a test, e.g.
6582

66-
public CustomerBuilder WhoJoinedIn(int yearJoined)
67-
{
68-
return Set(x => x.YearJoined, yearJoined);
69-
}
83+
var customer = new CustomerBuilder().WithFirstName("Robert").Build();
7084

71-
protected override Customer BuildObject()
72-
{
73-
return new Customer(
74-
Get(x => x.FirstName),
75-
Get(x => x.LastName),
76-
Get(x => x.YearJoined)
77-
);
78-
}
79-
}
80-
```
81-
3. Use the builder in a test, e.g.
82-
```c#
83-
var customer = new CustomerBuilder().WithFirstName("Robert").Build();
84-
```
8585
4. Consider using the Object Mother pattern in combination with the builders, see [my blog post](http://robdmoore.id.au/blog/2013/05/26/test-data-generation-the-right-way-object-mother-test-data-builders-nsubstitute-nbuilder/) for a description of how I use this library.
8686

8787
How can I create a list of entities using my builders?
@@ -187,10 +187,10 @@ If you need to alter the proxy before calling `Build` to add complex behaviours
187187

188188
*Remember that when using proxy objects of real classes that you need to mark properties and methods as virtual and have a protected empty constructor.*
189189

190-
Why does NTestDataBuilder have NSubstitute and AutoFixture as dependencies?
190+
Why does Dossier have NSubstitute and AutoFixture as dependencies?
191191
------------------------------------------------------------------------
192192

193-
NTestDataBuilder is an opinionated framework and as such prescribes how to build your fixture data, including how to build lists, anonymous data and mock objects. Because of this we have decided to bundle it with the best of breed libraries for this purpose: AutoFixture and NSubstitute.
193+
Dossier is an opinionated framework and as such prescribes how to build your fixture data, including how to build lists, anonymous data and mock objects. Because of this we have decided to bundle it with the best of breed libraries for this purpose: AutoFixture and NSubstitute.
194194

195195
This allows for this library to provide a rich value-add on top of the basics of tracking properties in a dictionary in the `TestDataBuilder` base class. If you want to use different libraries or want a cut down version that doesn't come with NSubstitute or AutoFixture and the extra functionality they bring then take the `TestDataBuilder.cs` file and cut out the bits you don't want - open source ftw :).
196196

NTestDataBuilder.Tests/AsProxyTests.cs TestStack.Dossier.Tests/AsProxyTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using NSubstitute;
3-
using NTestDataBuilder.Tests.Builders;
43
using Shouldly;
4+
using TestStack.Dossier.Tests.Builders;
55
using Xunit;
66

7-
namespace NTestDataBuilder.Tests
7+
namespace TestStack.Dossier.Tests
88
{
99
public class AsProxyTests
1010
{

NTestDataBuilder.Tests/BuildListTests.cs TestStack.Dossier.Tests/BuildListTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using NTestDataBuilder.DataSources.Generators;
4-
using NTestDataBuilder.Lists;
5-
using NTestDataBuilder.Tests.Builders;
6-
using NTestDataBuilder.Tests.Entities;
73
using Shouldly;
4+
using TestStack.Dossier.DataSources.Generators;
5+
using TestStack.Dossier.Lists;
6+
using TestStack.Dossier.Tests.Builders;
7+
using TestStack.Dossier.Tests.Entities;
88
using Xunit;
99

10-
namespace NTestDataBuilder.Tests
10+
namespace TestStack.Dossier.Tests
1111
{
1212
public class BuildListTests
1313
{

NTestDataBuilder.Tests/BuildTests.cs TestStack.Dossier.Tests/BuildTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using NTestDataBuilder.Tests.Builders;
2-
using NTestDataBuilder.Tests.Entities;
3-
using Shouldly;
1+
using Shouldly;
2+
using TestStack.Dossier.Tests.Builders;
3+
using TestStack.Dossier.Tests.Entities;
44
using Xunit;
55

6-
namespace NTestDataBuilder.Tests
6+
namespace TestStack.Dossier.Tests
77
{
88
public class BuildTests
99
{

NTestDataBuilder.Tests/Builders/BasicCustomerBuilder.cs TestStack.Dossier.Tests/Builders/BasicCustomerBuilder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Linq.Expressions;
3-
using NTestDataBuilder.Tests.Entities;
3+
using TestStack.Dossier.Tests.Entities;
44

5-
namespace NTestDataBuilder.Tests.Builders
5+
namespace TestStack.Dossier.Tests.Builders
66
{
77
public class BasicCustomerBuilder : TestDataBuilder<Customer, BasicCustomerBuilder>
88
{

NTestDataBuilder.Tests/Builders/CustomerBuilder.cs TestStack.Dossier.Tests/Builders/CustomerBuilder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using NTestDataBuilder.Tests.Entities;
1+
using TestStack.Dossier.Tests.Entities;
22

3-
namespace NTestDataBuilder.Tests.Builders
3+
namespace TestStack.Dossier.Tests.Builders
44
{
55
public class CustomerBuilder : TestDataBuilder<Customer, CustomerBuilder>
66
{

NTestDataBuilder.Tests/Builders/ProxyAlteringCustomerBuilder.cs TestStack.Dossier.Tests/Builders/ProxyAlteringCustomerBuilder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using NSubstitute;
3-
using NTestDataBuilder.Tests.Entities;
3+
using TestStack.Dossier.Tests.Entities;
44

5-
namespace NTestDataBuilder.Tests.Builders
5+
namespace TestStack.Dossier.Tests.Builders
66
{
77
class ProxyAlteringCustomerBuilder : TestDataBuilder<Customer, ProxyAlteringCustomerBuilder>
88
{

NTestDataBuilder.Tests/ChildBuilderTests.cs TestStack.Dossier.Tests/ChildBuilderTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Shouldly;
33
using Xunit;
44

5-
namespace NTestDataBuilder.Tests
5+
namespace TestStack.Dossier.Tests
66
{
77
public class ChildBuilderTests
88
{

NTestDataBuilder.Tests/DataSources/DataSourceConventionTests.cs TestStack.Dossier.Tests/DataSources/DataSourceConventionTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using NTestDataBuilder.DataSources;
4-
using NTestDataBuilder.DataSources.Geography;
5-
using NTestDataBuilder.DataSources.Person;
63
using Shouldly;
7-
using Xunit.Extensions;
4+
using TestStack.Dossier.DataSources;
5+
using TestStack.Dossier.DataSources.Geography;
6+
using TestStack.Dossier.DataSources.Person;
7+
using Xunit;
88

9-
namespace NTestDataBuilder.Tests.DataSources
9+
namespace TestStack.Dossier.Tests.DataSources
1010
{
1111
public class DataSourceConventionTests
1212
{
1313
[Theory]
14-
[PropertyData("TestCases")]
14+
[MemberData("TestCases")]
1515
public void DataSourceConventions(DataSource<string> sut, int expectedCount)
1616
{
1717
var collection = sut.Data.ToList();

NTestDataBuilder.Tests/DataSources/DataSourceTests.cs TestStack.Dossier.Tests/DataSources/DataSourceTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3-
using NTestDataBuilder.DataSources;
4-
using NTestDataBuilder.DataSources.Generators;
53
using Shouldly;
4+
using TestStack.Dossier.DataSources;
5+
using TestStack.Dossier.DataSources.Generators;
66
using Xunit;
77

8-
namespace NTestDataBuilder.Tests.DataSources
8+
namespace TestStack.Dossier.Tests.DataSources
99
{
1010
public class DataSourceTests
1111
{

NTestDataBuilder.Tests/DataSources/Dictionaries/CacheTests.cs TestStack.Dossier.Tests/DataSources/Dictionaries/CacheTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3-
using NTestDataBuilder.DataSources.Dictionaries;
43
using Shouldly;
4+
using TestStack.Dossier.DataSources.Dictionaries;
55
using Xunit;
66

7-
namespace NTestDataBuilder.Tests.DataSources.Dictionaries
7+
namespace TestStack.Dossier.Tests.DataSources.Dictionaries
88
{
99
public class CacheTests : IDisposable
1010
{

NTestDataBuilder.Tests/DataSources/Dictionaries/FileDictionaryRepositoryIntegrationTests.cs TestStack.Dossier.Tests/DataSources/Dictionaries/FileDictionaryRepositoryIntegrationTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.IO;
2-
using NTestDataBuilder.DataSources.Dictionaries;
32
using Shouldly;
3+
using TestStack.Dossier.DataSources.Dictionaries;
44
using Xunit;
55

6-
namespace NTestDataBuilder.Tests.DataSources.Dictionaries
6+
namespace TestStack.Dossier.Tests.DataSources.Dictionaries
77
{
88
public class FileDictionaryRepositoryIntegrationTests
99
{

NTestDataBuilder.Tests/DataSources/Dictionaries/FileDictionarySourceTests.cs TestStack.Dossier.Tests/DataSources/Dictionaries/FileDictionarySourceTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using NSubstitute;
2-
using NTestDataBuilder.DataSources.Dictionaries;
3-
using NTestDataBuilder.DataSources.Generators;
2+
using TestStack.Dossier.DataSources.Dictionaries;
3+
using TestStack.Dossier.DataSources.Generators;
44
using Xunit;
55

6-
namespace NTestDataBuilder.Tests.DataSources.Dictionaries
6+
namespace TestStack.Dossier.Tests.DataSources.Dictionaries
77
{
88
public class FileDictionarySourceTests
99
{

NTestDataBuilder.Tests/DataSources/Dictionaries/Resources/FileDataConventions.cs TestStack.Dossier.Tests/DataSources/Dictionaries/Resources/FileDataConventions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Text;
77
using Xunit;
88

9-
namespace NTestDataBuilder.Tests.DataSources.Dictionaries.Resources
9+
namespace TestStack.Dossier.Tests.DataSources.Dictionaries.Resources
1010
{
1111
public class FileDataConventions
1212
{

NTestDataBuilder.Tests/DataSources/Generators/RandomGeneratorTests.cs TestStack.Dossier.Tests/DataSources/Generators/RandomGeneratorTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3-
using NTestDataBuilder.DataSources.Generators;
43
using Shouldly;
4+
using TestStack.Dossier.DataSources.Generators;
55
using Xunit;
6-
using Xunit.Extensions;
76

8-
namespace NTestDataBuilder.Tests.DataSources.Generators
7+
namespace TestStack.Dossier.Tests.DataSources.Generators
98
{
109
public class RandomGeneratorTests
1110
{

NTestDataBuilder.Tests/DataSources/Generators/SequentiaGeneratorTests.cs TestStack.Dossier.Tests/DataSources/Generators/SequentiaGeneratorTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
2-
using NTestDataBuilder.DataSources.Generators;
32
using Shouldly;
3+
using TestStack.Dossier.DataSources.Generators;
44
using Xunit;
5-
using Xunit.Extensions;
65

7-
namespace NTestDataBuilder.Tests.DataSources.Generators
6+
namespace TestStack.Dossier.Tests.DataSources.Generators
87
{
98
public class SequentiaGeneratorTests
109
{

NTestDataBuilder.Tests/Entities/Company.cs TestStack.Dossier.Tests/Entities/Company.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace NTestDataBuilder.Tests.Entities
1+
namespace TestStack.Dossier.Tests.Entities
22
{
33
public class Company
44
{

NTestDataBuilder.Tests/Entities/Customer.cs TestStack.Dossier.Tests/Entities/Customer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace NTestDataBuilder.Tests.Entities
3+
namespace TestStack.Dossier.Tests.Entities
44
{
55
public class Customer
66
{

0 commit comments

Comments
 (0)