Skip to content

Commit b20f77a

Browse files
committed
Merge branch 'release/2.1.x'
2 parents e249a63 + 255858e commit b20f77a

36 files changed

+1269
-442
lines changed

CHANGELOG.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44

55
Full documentation on usage and motivating examples at https://github.com/kbilsted/StatePrinter/tree/master/doc
66

7-
8-
## v2.1.198-rc
7+
## v2.1.xx
98

109
Added
1110

12-
* Functionality for including or excluding fields and properties based on one or more type descriptions. See IncludeByType() and ExcludeByType()
13-
14-
## v2.1.186-rc
11+
* Functionality for controlling automatic test rewrite using an environment variable.
12+
* Functionality for including or excluding fields and properties based on one or more type descriptions. See `IncludeByType()` and `ExcludeByType()`.
13+
* Added `AreAlike()`, replacing `IsSame()` (which is deprecated). Similar story for `PrintAreAlike` replacing `PrintIsSame()`.
14+
* Made error message tell about `AreAlike()` when two strings are alike but not equals, when using `AreEquals()`.
15+
* Prepared for future expansion of functionality, by placing unit testing configuration in a sub-configuration class.
16+
* Obsoleted a lot of methods, describing the alternative API introduced in v2.1
17+
1518

1619
Fixed
1720

1821
* [#22 Make error message configurable upon assertion failure](https://github.com/kbilsted/StatePrinter/issues/22)
1922

20-
Added
21-
22-
* Added `AreAlike()`, replacing `IsSame()` (which is deprecated).
23-
* Made error message tell about `AreAlike()` when two strings are alike but not equals, when using `AreEquals()`.
24-
* Prepared for future expansion of functionality, by placing unit testing configuration in a sub-configuration class.
2523

2624

2725

DeployToNuget.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ REM ON FIRST RUN, RUN THIS (change the key to whatever is found on your profile
22
REM .nuget\NuGet.exe setapikey e39ea-get-the-full-key-on-nuget.org
33

44
call CreateNuget.cmd
5-
.nuget\NuGet.exe push nuget_packages\StatePrinter.2.0.*.nupkg
6-
.nuget\NuGet.exe push nuget_packages\StatePrinter.2.0.*.symbols.nupkg
5+
.nuget\NuGet.exe push nuget_packages\StatePrinter.2.*.*.symbols.nupkg
6+
.nuget\NuGet.exe push nuget_packages\StatePrinter.2.*.*.nupkg
77

88
cd nuget_packages
99
del /q *

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# ![](https://raw.github.com/kbilsted/StatePrinter/master/StatePrinter/gfx/stateprinter.png) StatePrinter
22

3-
[![Join the chat at https://gitter.im/kbilsted/StatePrinter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbilsted/StatePrinter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
53
[![Build status](https://ci.appveyor.com/api/projects/status/vx0nl4y4iins506u/branch/master?svg=true)](https://ci.appveyor.com/project/kbilsted/stateprinter/branch/master)
64
[![Nuget](https://img.shields.io/nuget/dt/stateprinter.svg)](http://nuget.org/packages/stateprinter)
75
[![Nuget](https://img.shields.io/nuget/v/stateprinter.svg)](http://nuget.org/packages/stateprinter)
@@ -10,14 +8,14 @@
108
[![Stats](https://img.shields.io/badge/Code_lines-3,3_K-ff69b4.svg)]()
119
[![Stats](https://img.shields.io/badge/Doc_lines-1,4_K-ff69b4.svg)]()
1210

13-
# What is Stateprinter
14-
A simple framework for **automatic** `Assert.AreEquals()`, `Assert.That()` and `ToString()`
11+
[![Join the chat at https://gitter.im/kbilsted/StatePrinter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbilsted/StatePrinter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1512

16-
StatePrinter is a little library that turn any object-graph into a string representation. It is mainly intended automating writing `ToString` methods and help automating aspects of writing and maintaining unit tests. Code which is rather dreary and boring to write.
13+
# What is Stateprinter
14+
A simple framework for **automating** aspects of unit testing and implementing ToString methods.
1715

1816
Why you should take StatePrinter for a spin
1917

20-
* *No more manual .ToString()* - it is much easier to write robus and self-sufficient `ToString()` methods.
18+
* *No more manual .ToString()* - it is much easier to write robust and self-sufficient `ToString()` methods.
2119
* *No more manual writing/updating Asserts* - both for new tests and when the code changes, all tests can automatically be corrected.
2220
* *No more screens full of asserts*. Especially testing against object-graphs is a bliss.
2321
* Very configurable and extensible.
@@ -26,9 +24,10 @@ Why you should take StatePrinter for a spin
2624

2725

2826

29-
# How do I get started
27+
## How do I get started
3028

3129
The documentation is split into
30+
3231
* [Automating ToStrings](https://github.com/kbilsted/StatePrinter/blob/master/doc/AutomatingToStrings.md)
3332

3433
and
@@ -41,7 +40,7 @@ and
4140
* [Configuration and exension](https://github.com/kbilsted/StatePrinter/blob/master/doc/HowToConfigure.md)
4241

4342

44-
# Where can I get it?
43+
## Where can I get it?
4544
Install Stateprinter from the package manager console:
4645

4746
```
@@ -55,12 +54,12 @@ PM> Install-Package StatePrinter -Pre
5554
```
5655

5756

58-
# How can I get help?
57+
## How can I get help?
5958
For quick questions, [Stack Overflow](http://stackoverflow.com/questions/tagged/stateprinter?sort=newest) is your best bet. For harder questions, bugs, issues or feature requests, [create a GitHub Issue (and let's chat)](https://github.com/kbilsted/StatePrinter/issues/new).
6059

6160

6261

63-
# How can I help out
62+
## How can I help out
6463
Everyone is encouraged to help improve this project. Here are a few ways you can help:
6564
* Blog about your experinces with the tool. We highly need publicity. I'll gladly link from here to your blog.
6665
* [Report bugs](https://github.com/kbilsted/StatePrinter/issues/new)
@@ -73,23 +72,41 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
7372

7473

7574

76-
# History
75+
## Versioning
76+
Stateprinter is maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:
77+
78+
`<major>.<minor>.<build>`
79+
80+
and constructed with the following guidelines:
81+
82+
* Breaking backward compatibility bumps the major
83+
* New additions without breaking backward compatibility bumps the minor
84+
* Bug fixes and misc changes increase the build number
85+
86+
For more information on SemVer, please visit http://semver.org/.
87+
88+
89+
90+
## History
7791
Version History: http://github.com/kbilsted/StatePrinter/blob/master/CHANGELOG.md
7892

7993
This file describes the latest pushed changes. For documentation of earlier releases see:
8094
[1.0.6](https://github.com/kbilsted/StatePrinter/blob/1.0.6/README.md), [1.0.5](https://github.com/kbilsted/StatePrinter/blob/1.0.5/README.md), [1.0.4](https://github.com/kbilsted/StatePrinter/blob/1.0.4/README.md)
8195

8296
Upgrading from v1.xx to v2.0.x should be a matter of configuring the `Configuration.LegacyBehaviour`
8397

98+
Upgrading from v2.0 to v2.1 simply follow the documentation in the obsolete attributes.
99+
100+
84101

85102

86-
# Requirements
103+
## Requirements
87104
Requires .NET 3.5 or newer.
88105

89106

90107

91108

92-
# License
109+
## License
93110
Stateprinter is under the Apache License 2.0, meaning that you can freely use this in other open source or commercial products. If you use it for commercial products please have the courtesy to leave me an email with a 'thank you'.
94111

95112

StatePrinter.Tests/Configurations/ConfigurationTest.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Linq;
2222
using NUnit.Framework;
2323
using StatePrinter.Configurations;
24+
using StatePrinter.FieldHarvesters;
2425
using StatePrinter.ValueConverters;
2526

2627
namespace StatePrinter.Tests.Configurations
@@ -44,9 +45,17 @@ public void SettingNullValues()
4445
{
4546
var sut = new Configuration();
4647
Assert.Throws<ArgumentNullException>(() => sut.SetCulture(null));
48+
Assert.Throws<ArgumentNullException>(() => sut.SetIndentIncrement(null));
4749
Assert.Throws<ArgumentNullException>(() => sut.SetNewlineDefinition(null));
50+
Assert.Throws<ArgumentNullException>(() => sut.SetOutputFormatter(null));
4851
Assert.Throws<ArgumentNullException>(() => sut.SetAreEqualsMethod(null));
49-
Assert.Throws<ArgumentNullException>(() => sut.SetAutomaticTestRewrite(null));
52+
53+
Assert.Throws<ArgumentNullException>(() => sut.Add((IFieldHarvester)null));
54+
Assert.Throws<ArgumentNullException>(() => sut.Add((IValueConverter)null));
55+
56+
57+
Assert.Throws<ArgumentNullException>(() => sut.Test.SetAreEqualsMethod(null));
58+
Assert.Throws<ArgumentNullException>(() => sut.Test.SetAutomaticTestRewrite(null));
5059
}
5160
}
5261
}

StatePrinter.Tests/ExamplesForDocumentation/ExampleEndlessAsserts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void EndlessAssertsAlternative()
6161
PremiumInternalCostAfterDiscount = 37
6262
Tax = 110
6363
}";
64-
printer.Assert.PrintIsSame(expected, allocateData);
64+
printer.Assert.PrintAreAlike(expected, allocateData);
6565
}
6666

6767
}

StatePrinter.Tests/ExamplesForDocumentation/ExampleListAndArrays.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void ExampleListAndArraysAlternative()
6666
Share = 50
6767
}";
6868

69-
TestHelper.CreateTestPrinter().Assert.PrintIsSame(expected, vendorManager.VendorJobSplit);
69+
TestHelper.Assert().PrintAreAlike(expected, vendorManager.VendorJobSplit);
7070
}
7171
}
7272

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright 2014 Kasper B. Graversen
2+
//
3+
// Licensed to the Apache Software Foundation (ASF) under one
4+
// or more contributor license agreements. See the NOTICE file
5+
// distributed with this work for additional information
6+
// regarding copyright ownership. The ASF licenses this file
7+
// to you under the Apache License, Version 2.0 (the
8+
// "License"); you may not use this file except in compliance
9+
// with the License. You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing,
14+
// software distributed under the License is distributed on an
15+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
// KIND, either express or implied. See the License for the
17+
// specific language governing permissions and limitations
18+
// under the License.
19+
20+
using NUnit.Framework;
21+
22+
using StatePrinter.TestAssistance;
23+
24+
namespace StatePrinter.Tests.FieldHarvesters
25+
{
26+
[TestFixture]
27+
public class TypeFilteringTests
28+
{
29+
interface IA
30+
{
31+
int A { get; set; }
32+
}
33+
34+
interface IB
35+
{
36+
int B { get; set; }
37+
}
38+
39+
interface IC
40+
{
41+
int C { get; set; }
42+
}
43+
44+
interface ID
45+
{
46+
int D { get; set; }
47+
}
48+
49+
class AtoD : IA, IB, IC, ID
50+
{
51+
public int A { get; set; }
52+
public int B { get; set; }
53+
public int C { get; set; }
54+
public int D { get; set; }
55+
56+
public AtoD()
57+
{
58+
A = 1;
59+
B = 2;
60+
C = 3;
61+
D = 4;
62+
}
63+
}
64+
65+
[Test]
66+
public void TestIncludeByType()
67+
{
68+
var sut = new AtoD();
69+
Asserter assert;
70+
71+
assert = TestHelper.CreateShortAsserter();
72+
assert.PrintEquals("new AtoD() { A = 1 B = 2 C = 3 D = 4 }", sut);
73+
74+
assert = TestHelper.CreateShortAsserter();
75+
assert.Project.IncludeByType<AtoD, IA>();
76+
assert.PrintEquals("new AtoD() { A = 1 }", sut);
77+
78+
assert = TestHelper.CreateShortAsserter();
79+
assert.Project.IncludeByType<AtoD, IA, IB>();
80+
assert.PrintEquals("new AtoD() { A = 1 B = 2 }", sut);
81+
82+
assert = TestHelper.CreateShortAsserter();
83+
assert.Project.IncludeByType<AtoD, IA, IB, IC>();
84+
assert.PrintEquals("new AtoD() { A = 1 B = 2 C = 3 }", sut);
85+
86+
assert = TestHelper.CreateShortAsserter();
87+
assert.Project.IncludeByType<AtoD, IA, IB, IC, ID>();
88+
assert.PrintEquals("new AtoD() { A = 1 B = 2 C = 3 D = 4 }", sut);
89+
}
90+
91+
[Test]
92+
public void TestExcludeByType()
93+
{
94+
var sut = new AtoD();
95+
Asserter assert;
96+
97+
assert = TestHelper.CreateShortAsserter();
98+
assert.PrintEquals("new AtoD() { A = 1 B = 2 C = 3 D = 4 }", sut);
99+
100+
assert = TestHelper.CreateShortAsserter();
101+
assert.Project.ExcludeByType<AtoD, IA>();
102+
assert.PrintEquals("new AtoD() { B = 2 C = 3 D = 4 }", sut);
103+
104+
assert = TestHelper.CreateShortAsserter();
105+
assert.Project.ExcludeByType<AtoD, IA, IB>();
106+
assert.PrintEquals("new AtoD() { C = 3 D = 4 }", sut);
107+
108+
assert = TestHelper.CreateShortAsserter();
109+
assert.Project.ExcludeByType<AtoD, IA, IB, IC>();
110+
assert.PrintEquals("new AtoD() { D = 4 }", sut);
111+
112+
assert = TestHelper.CreateShortAsserter();
113+
assert.Project.ExcludeByType<AtoD, IA, IB, IC, ID>();
114+
assert.PrintEquals("new AtoD() { }", sut);
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)