Skip to content

Commit 2ff3790

Browse files
committed
Merge pull request #21 from robdmoore/dossier-rename
Dossier rename
2 parents 260c67d + aa325b6 commit 2ff3790

File tree

151 files changed

+342
-319
lines changed

Some content is hidden

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

151 files changed

+342
-319
lines changed

BREAKING_CHANGES.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
NTestDataBuilder Breaking Changes
2-
=================================
1+
Breaking Changes
2+
================
33

4-
Version 2.0.0
5-
-------------
4+
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
5+
--------------------------------------------------------------
6+
7+
Namespace has changed from NTestDataBuilder to TestStack.Dossier.
8+
9+
### Reason
10+
11+
The project has been renamed.
12+
13+
### Fix
14+
15+
Do a global find and replace of `using NTestDataBuilder` with `using TestStack.Dossier`.
16+
17+
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
18+
--------------------------------------------------------------
619

720
When you don't `Set` a default value for a property that you later `Get` in your builder it will now generate an anonymous value for that property rather than throwing an exception.
821

@@ -16,8 +29,8 @@ The old behaviour of throwing an exception if a value hasn't been specified is n
1629

1730
If you want to fix a static value for a property then by all means you can still use `Set` calls in your builder constructor. If you aren't happy with the default anonymous value that is generated for a property you can use the `Any` property to generate a value from a different equivalence class in combination with a `Set` call in your builder constructor.
1831

19-
Version 2.0.0
20-
-------------
32+
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
33+
--------------------------------------------------------------
2134

2235
The way that lists are generated no longer uses NBuilder - the new syntax is backwards compatible with NBuilder except that the namespace you need to include is different. You can also refactor your list generation to be a lot more terse, but that is optional. Any `BuildList` extension methods you created will now need to be deleted since they are no longer needed. You also need to ensure that all of the methods you call are marked virtual so the list generation can proxy those method calls.
2336

@@ -47,10 +60,10 @@ You also no longer need a custom extension method for the `BuildList` method so
4760
Simply add the following to the files that generate lists of builders and change your builder modification methods to be virtual and the existing syntax should work:
4861

4962
```
50-
using NTestDataBuilder.Lists;
63+
using TestStack.Dossier.Lists;
5164
```
5265

53-
Assuming you aren't using NBuilder for anything other than generating lists of entities with NTestDataBuilder 1.0 you should be abke to do a global find and replace against `using FizzWare.NBuilder;`.
66+
Assuming you aren't using NBuilder for anything other than generating lists of entities with NTestDataBuilder 1.0 you should be able to do a global find and replace against `using FizzWare.NBuilder;`.
5467

5568
If you uninstall the NBuilder package then you will need to remove the using statements for that library too.
5669

NTestDataBuilder.Tests/packages.config

Lines changed: 0 additions & 8 deletions
This file was deleted.

NTestDataBuilder/NTestDataBuilder.nuspec

Lines changed: 0 additions & 42 deletions
This file was deleted.

README.md

Lines changed: 74 additions & 74 deletions
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 renamed to TestStack.Dossier.Tests/AsProxyTests.cs

Lines changed: 2 additions & 2 deletions
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 renamed to TestStack.Dossier.Tests/BuildListTests.cs

Lines changed: 5 additions & 5 deletions
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 renamed to TestStack.Dossier.Tests/BuildTests.cs

Lines changed: 4 additions & 4 deletions
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 renamed to TestStack.Dossier.Tests/Builders/BasicCustomerBuilder.cs

Lines changed: 2 additions & 2 deletions
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 renamed to TestStack.Dossier.Tests/Builders/CustomerBuilder.cs

Lines changed: 2 additions & 2 deletions
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 renamed to TestStack.Dossier.Tests/Builders/ProxyAlteringCustomerBuilder.cs

Lines changed: 2 additions & 2 deletions
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
{

0 commit comments

Comments
 (0)