Skip to content

Commit e0d928f

Browse files
committed
Removed the redundant method in AnonymousValueFixture and bumped to v3.0 due to the breaking change
1 parent a28a6be commit e0d928f

12 files changed

+43
-58
lines changed

BREAKING_CHANGES.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
11
Breaking Changes
22
================
33

4-
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
4+
Version 3.0
5+
-----------
6+
7+
The signature of `IAnonymousValueSupplier` has changed from:
8+
9+
```c#
10+
public interface IAnonymousValueSupplier
11+
{
12+
bool CanSupplyValue(Type type, string propertyName);
13+
TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName);
14+
}
15+
```
16+
17+
To:
18+
19+
```c#
20+
public interface IAnonymousValueSupplier
21+
{
22+
bool CanSupplyValue(Type type, string propertyName);
23+
object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName);
24+
}
25+
```
26+
27+
Note: the `GenerateAnonymousValue` method is no longer generic.
28+
29+
### Reason
30+
31+
In order to implement the `BuildUsing` method that allows you to build an object by convention in one line rather than having to call the constructor yourself we needed to have a non-generic version of the method. This change actually ended up making the anonymous value suppliers slightly easier to implement (no longer any need for type casting).
32+
33+
### Fix
34+
35+
If you have any custom anonymous value suppliers change the signature of your `GenerateAnonymousValue` method so it's no logner generic.
36+
37+
Breaking change from NTestDataBuilder -> TestStack.Dossier 2.0
538
--------------------------------------------------------------
639

740
Namespace has changed from NTestDataBuilder to TestStack.Dossier.
@@ -14,7 +47,7 @@ The project has been renamed.
1447

1548
Do a global find and replace of `using NTestDataBuilder` with `using TestStack.Dossier`.
1649

17-
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
50+
Breaking change from NTestDataBuilder -> TestStack.Dossier 2.0
1851
--------------------------------------------------------------
1952

2053
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.
@@ -29,7 +62,7 @@ The old behaviour of throwing an exception if a value hasn't been specified is n
2962

3063
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.
3164

32-
Breaking change from NTestDataBuilder -> TestStack.Dossier 1.0
65+
Breaking change from NTestDataBuilder -> TestStack.Dossier 2.0
3366
--------------------------------------------------------------
3467

3568
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.

NextVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.0
1+
3.0.0

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Linq.Expressions;
3-
using TestStack.Dossier.Tests.TestHelpers.Objects.Entities;
1+
using TestStack.Dossier.Tests.TestHelpers.Objects.Entities;
42

53
namespace TestStack.Dossier.Tests.TestHelpers.Builders
64
{

TestStack.Dossier.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
4+
VisualStudioVersion = 12.0.30723.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BC8508D1-6FCB-46B2-9C14-F41F6AD76B09}"
77
ProjectSection(SolutionItems) = preProject
88
BREAKING_CHANGES.md = BREAKING_CHANGES.md
99
LICENSE = LICENSE
1010
logo.png = logo.png
11+
NextVersion.txt = NextVersion.txt
1112
README.md = README.md
1213
EndProjectSection
1314
EndProject

TestStack.Dossier/AnonymousValueFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public T Get<TObject, T>(Expression<Func<TObject, T>> property)
8888
.Concat(DefaultValueSuppliers)
8989
.First(s => s.CanSupplyValue(typeof(T), propertyName));
9090

91-
return valueSupplier.GenerateAnonymousValue<TObject, T>(this, propertyName);
91+
return (T) valueSupplier.GenerateAnonymousValue(this, typeof(T), propertyName);
9292
}
9393

9494
/// <summary>
@@ -102,7 +102,7 @@ public object Get(Type type, string propertyName)
102102
var valueSupplier = LocalValueSuppliers
103103
.Concat(GlobalValueSuppliers)
104104
.Concat(DefaultValueSuppliers)
105-
.First(s => s.CanSupplyValue(type,propertyName));
105+
.First(s => s.CanSupplyValue(type, propertyName));
106106

107107
return valueSupplier.GenerateAnonymousValue(this, type, propertyName);
108108
}

TestStack.Dossier/IAnonymousValueSupplier.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ public interface IAnonymousValueSupplier
1515
/// <returns>Whether or not this supplier can supply an anonymous value</returns>
1616
bool CanSupplyValue(Type type, string propertyName);
1717

18-
/// <summary>
19-
/// Return an anonymous value for the given property and fixture.
20-
/// </summary>
21-
/// <typeparam name="TObject">The type that the property is enclosed in</typeparam>
22-
/// <typeparam name="TValue">The type of the target property - the required anonymous value is of this type</typeparam>
23-
/// <param name="any">Anonymous value fixture</param>
24-
/// <param name="propertyName">The name of the property to return an anonymous value for</param>
25-
/// <returns>The anonymous value</returns>
26-
TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName);
27-
2818
/// <summary>
2919
/// Return an anonymous value for the given property and fixture.
3020
/// </summary>

TestStack.Dossier/Suppliers/DefaultEmailValueSupplier.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ public bool CanSupplyValue(Type type, string propertyName)
1414
return type == typeof(string) && propertyName.ToLower().Contains("email");
1515
}
1616

17-
/// <inheritdoc />
18-
public TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName)
19-
{
20-
return (TValue) (object) any.EmailAddress();
21-
}
22-
2317
/// <inheritdoc />
2418
public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName)
2519
{

TestStack.Dossier/Suppliers/DefaultFirstNameValueSupplier.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ public bool CanSupplyValue(Type type, string propertyName)
1414
return type == typeof(string) && propertyName.ToLower() == "firstname";
1515
}
1616

17-
/// <inheritdoc />
18-
public TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName)
19-
{
20-
return (TValue) (object) any.FirstName();
21-
}
22-
2317
/// <inheritdoc />
2418
public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName)
2519
{

TestStack.Dossier/Suppliers/DefaultLastNameValueSupplier.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ public bool CanSupplyValue(Type type, string propertyName)
1515
(propertyName.ToLower() == "lastname" || propertyName.ToLower() == "surname");
1616
}
1717

18-
/// <inheritdoc />
19-
public TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName)
20-
{
21-
return (TValue)(object)any.LastName();
22-
}
23-
2418
/// <inheritdoc />
2519
public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName)
2620
{

TestStack.Dossier/Suppliers/DefaultStringValueSupplier.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ public bool CanSupplyValue(Type type, string propertyName)
1414
return type == typeof(string);
1515
}
1616

17-
/// <inheritdoc />
18-
public TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName)
19-
{
20-
return (TValue) (object) any.StringStartingWith(propertyName);
21-
}
22-
2317
/// <inheritdoc />
2418
public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName)
2519
{

0 commit comments

Comments
 (0)