Skip to content

Commit a3f59d4

Browse files
committed
Updated projects after migration
1 parent 85cf40f commit a3f59d4

File tree

10 files changed

+96
-409
lines changed

10 files changed

+96
-409
lines changed

.github/workflows/continuous.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
- uses: actions/setup-dotnet@v4
3434
with:
3535
dotnet-version: |
36-
5.0.x
3736
6.0.x
3837
- name: Cache .nuke/temp, ~/.nuget/packages
3938
uses: actions/cache@v4

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
- uses: actions/setup-dotnet@v4
3333
with:
3434
dotnet-version: |
35-
5.0.x
3635
6.0.x
3736
- name: Cache .nuke/temp, ~/.nuget/packages
3837
uses: actions/cache@v4

AutoFixture.sln

Lines changed: 1 addition & 260 deletions
Large diffs are not rendered by default.

Common.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
<!-- NuGet options -->
2828
<Authors>AutoFixture Contributors</Authors>
29-
<PackageProjectUrl>https://github.com/AutoFixture/AutoFixture</PackageProjectUrl>
29+
<PackageProjectUrl>https://github.com/AutoFixture/AutoFixture.NUnit2</PackageProjectUrl>
3030
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3131
<PackageLicenseExpression>MIT</PackageLicenseExpression>
3232
<PackageIconUrl>https://raw.githubusercontent.com/AutoFixture/AutoFixture/79c882c3f4af3cf52ad43e5c95851f25d217ac17/AutoFixtureLogo200x200.png</PackageIconUrl>
3333
<PackageIcon>icon.png</PackageIcon>
34+
<PackageReadmeFile>README.md</PackageReadmeFile>
3435
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
3536
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3637
</PropertyGroup>
@@ -40,6 +41,7 @@
4041
</ItemGroup>
4142

4243
<ItemGroup>
44+
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
4345
<None Include="$(MSBuildThisFileDirectory)\AutoFixtureLogo200x200.png" Pack="true" PackagePath="icon.png"/>
4446
</ItemGroup>
4547

README.md

Lines changed: 86 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,123 @@
1-
# AutoFixture
1+
# AutoFixture.NUnit2
22

3-
[![License](https://img.shields.io/badge/license-MIT-green)](https://raw.githubusercontent.com/AutoFixture/AutoFixture/master/LICENCE.txt)
4-
[![release](https://github.com/AutoFixture/AutoFixture/actions/workflows/release.yml/badge.svg)](https://github.com/AutoFixture/AutoFixture/actions/workflows/release.yml)
5-
[![NuGet version](https://img.shields.io/nuget/v/AutoFixture?logo=nuget)](https://www.nuget.org/packages/AutoFixture)
6-
[![NuGet preview version](https://img.shields.io/nuget/vpre/AutoFixture?logo=nuget)](https://www.nuget.org/packages/AutoFixture)
7-
[![NuGet downloads](https://img.shields.io/nuget/dt/AutoFixture)](https://www.nuget.org/packages/AutoFixture)
8-
<a href="https://x.com/AutoFixture">
9-
<img src="https://img.shields.io/twitter/follow/AutoFixture?label=%40AutoFixture" alt="AutoFixture" align="right" />
10-
</a>
3+
[![License](https://img.shields.io/badge/license-MIT-green)](https://raw.githubusercontent.com/AutoFixture/AutoFixture.NUnit2/master/LICENCE.txt)
4+
[![NuGet version](https://img.shields.io/nuget/v/AutoFixture.NUnit2?logo=nuget)](https://www.nuget.org/packages/AutoFixture.NUnit2)
5+
[![NuGet preview version](https://img.shields.io/nuget/vpre/AutoFixture.NUnit2?logo=nuget)](https://www.nuget.org/packages/AutoFixture.NUnit2)
6+
[![NuGet downloads](https://img.shields.io/nuget/dt/AutoFixture.NUnit2)](https://www.nuget.org/packages/AutoFixture.NUnit2)
117

12-
Write maintainable unit tests, faster.
8+
[AutoFixture.NUnit2](https://github.com/AutoFixture/AutoFixture.NUnit2) is a .NET library that integrates [AutoFixture](https://github.com/AutoFixture/AutoFixture) with NUnit 2.x, allowing you to effortlessly generate test data for your unit tests.
9+
By automatically populating your test parameters, it helps you write cleaner, more maintainable tests without having to manually construct test objects.
1310

14-
AutoFixture makes it easier for developers to do Test-Driven Development by automating non-relevant Test Fixture Setup, allowing the Test Developer to focus on the essentials of each test case.
15-
16-
Check the [testimonials](https://github.com/AutoFixture/AutoFixture/wiki/Who-uses-AutoFixture) to see what other people have to say about AutoFixture.
11+
> [!WARNING]
12+
> While this package is still being developed, the NUnit 2 package is deprecated.<br/>
13+
> This package is intended for legacy projects that are still using NUnit 2.x.<br/>
14+
> Use at your own risk.
1715
1816
## Table of Contents
1917

20-
- [Overview](#overview)
21-
- [Downloads](#downloads)
22-
- [Documentation](#documentation)
23-
- [Feedback & Questions](#feedback--questions)
18+
- [Installation](#installation)
19+
- [Getting Started](#getting-started)
20+
- [Integrations](#integrations)
2421
- [License](#license)
2522

26-
## Overview
27-
28-
(Jump straight to the [CheatSheet](https://github.com/AutoFixture/AutoFixture/wiki/Cheat-Sheet) if you just want to see some code samples right away.)
29-
30-
AutoFixture is designed to make Test-Driven Development more productive and unit tests more refactoring-safe. It does so by removing the need for hand-coding anonymous variables as part of a test's Fixture Setup phase. Among other features, it offers a generic implementation of the [Test Data Builder](http://www.natpryce.com/articles/000714.html) pattern.
23+
## Installation
3124

32-
When writing unit tests, you typically need to create some objects that represent the initial state of the test. Often, an API will force you to specify much more data than you really care about, so you frequently end up creating objects that has no influence on the test, simply to make the code compile.
25+
AutoFixture packages are distributed via NuGet.<br />
26+
To install the packages you can use the integrated package manager of your IDE, the .NET CLI, or reference the package directly in your project file.
3327

34-
AutoFixture can help by creating such [Anonymous Variables](https://docs.microsoft.com/en-us/archive/blogs/ploeh/anonymous-variables) for you. Here's a simple example:
28+
```cmd
29+
dotnet add package AutoFixture.NUnit2 --version x.x.x
30+
```
3531

36-
```c#
37-
[Fact]
38-
public void IntroductoryTest()
39-
{
40-
// Arrange
41-
Fixture fixture = new Fixture();
42-
43-
int expectedNumber = fixture.Create<int>();
44-
MyClass sut = fixture.Create<MyClass>();
45-
// Act
46-
int result = sut.Echo(expectedNumber);
47-
// Assert
48-
Assert.Equal(expectedNumber, result);
49-
}
32+
```xml
33+
<PackageReference Include="AutoFixture.NUnit2" Version="x.x.x" />
5034
```
5135

52-
This example illustrates the basic principle of AutoFixture: It can create values of virtually any type without the need for you to explicitly define which values should be used. The number *expectedNumber* is created by a call to `Create<T>` - this will create a 'nice', regular integer value, saving you the effort of explicitly coming up with one.
36+
## Getting Started
5337

54-
The example also illustrates how AutoFixture can be used as a [SUT Factory](http://blog.ploeh.dk/2009/02/13/SUTFactory.aspx) that creates the actual System Under Test (the MyClass instance).
38+
### Basic Usage
5539

56-
Given the right combination of unit testing framework and extensions for AutoFixture, we can further reduce the above test to be even more declarative:
40+
`AutoFixture.NUnit2` provides an `[AutoData]` attribute that automatically populates test method parameters with generated data.
5741

58-
### [xUnit](http://blog.ploeh.dk/2010/10/08/AutoDataTheoriesWithAutoFixture.aspx)
42+
For example, imagine you have a simple calculator class:
5943

6044
```c#
61-
[Theory, AutoData]
62-
public void IntroductoryTest(int expectedNumber, MyClass sut)
45+
public class Calculator
6346
{
64-
int result = sut.Echo(expectedNumber);
65-
Assert.Equal(expectedNumber, result);
47+
public int Add(int a, int b) => a + b;
6648
}
6749
```
6850

69-
### [NUnit](http://gertjvr.wordpress.com/2013/09/25/howto-autofixture-nunit2)
51+
You can write a test using AutoFixture to provide the input values:
7052

7153
```c#
72-
[Test, AutoData]
73-
public void IntroductoryTest(int expectedNumber, MyClass sut)
54+
using NUnit.Framework;
55+
using AutoFixture.NUnit2;
56+
57+
[TestFixture]
58+
public class CalculatorTests
7459
{
75-
int result = sut.Echo(expectedNumber);
76-
Assert.Equal(expectedNumber, result);
60+
[Test, AutoData]
61+
public void Add_SimpleValues_ReturnsCorrectResult(
62+
Calculator calculator, int a, int b)
63+
{
64+
// Act
65+
int result = calculator.Add(a, b);
66+
67+
// Assert
68+
Assert.AreEqual(a + b, result);
69+
}
7770
}
7871
```
7972

80-
Notice how we can reduce unit tests to state only the relevant parts of the test. The rest (variables, Fixture object) is relegated to attributes and parameter values that are supplied automatically by AutoFixture. The test is now only two lines of code.
73+
### Freezing Dependencies
8174

82-
Using AutoFixture is as easy as referencing the library and creating a new instance of the Fixture class!
75+
AutoFixture's `[Frozen]` attribute can be used to ensure that the same instance of a dependency is injected into multiple parameters.
8376

84-
## Downloads
77+
For example, if you have a consumer class that depends on a shared dependency:
8578

86-
AutoFixture packages are distributed via NuGet.<br />
87-
To install the packages you can use the integrated package manager of your IDE, the .NET CLI, or reference the package directly in your project file.
79+
```c#
80+
public class Dependency { }
8881

89-
```cmd
90-
dotnet add package AutoFixture --version 4.18.0
82+
public class Consumer
83+
{
84+
public Dependency Dependency { get; }
85+
86+
public Consumer(Dependency dependency)
87+
{
88+
Dependency = dependency;
89+
}
90+
}
9191
```
9292

93-
```xml
94-
<PackageReference Include="AutoFixture" Version="4.18.0" />
93+
You can freeze the Dependency so that all requests for it within the test will return the same instance:
94+
95+
```c#
96+
using NUnit.Framework;
97+
using AutoFixture.NUnit2;
98+
using AutoFixture;
99+
100+
[TestFixture]
101+
public class ConsumerTests
102+
{
103+
[Test, AutoData]
104+
public void Consumer_UsesSameDependency(
105+
[Frozen] Dependency dependency, Consumer consumer)
106+
{
107+
// Assert
108+
Assert.AreSame(dependency, consumer.Dependency);
109+
}
110+
}
95111
```
96112

113+
## Integrations
114+
97115
AutoFixture offers a variety of utility packages and integrations with most of the major mocking libraries and testing frameworks.
98116

117+
> [!NOTE]
118+
> Since AutoFixture tries maintain compatibility with a large number of package versions, the packages bundled with AutoFixture might not contain the latest features of your (e.g. mocking) library.<br />
119+
> Make sure to install the latest version of the integrated library package, alongside the AutoFixture packages.
120+
99121
### Core packages
100122

101123
The core packages offer the full set of AutoFixture's features without requring any testing framework or third party integration.
@@ -118,10 +140,6 @@ These integrations enable such features as configuring mocks, auto-injecting moc
118140
| FakeItEasy | [AutoFixture.AutoFakeItEasy](http://www.nuget.org/packages/AutoFixture.AutoFakeItEasy) | [![NuGet](https://img.shields.io/nuget/v/AutoFixture.AutoFakeItEasy)](https://www.nuget.org/packages/AutoFixture.AutoFakeItEasy) | [![NuGet](https://img.shields.io/nuget/vpre/AutoFixture.AutoFakeItEasy)](https://www.nuget.org/packages/AutoFixture.AutoFakeItEasy) | ![NuGet](https://img.shields.io/nuget/dt/autofixture.AutoFakeItEasy) |
119141
| Rhino Mocks | [AutoFixture.AutoRhinoMocks](http://www.nuget.org/packages/AutoFixture.AutoRhinoMocks) | [![NuGet](https://img.shields.io/nuget/v/AutoFixture.AutoRhinoMocks)](https://www.nuget.org/packages/AutoFixture.AutoRhinoMocks) | [![NuGet](https://img.shields.io/nuget/vpre/AutoFixture.AutoRhinoMocks)](https://www.nuget.org/packages/AutoFixture.AutoRhinoMocks) | ![NuGet](https://img.shields.io/nuget/dt/autofixture.AutoRhinoMocks) |
120142

121-
> **NOTE:**
122-
> Since AutoFixture tries maintain compatibility with a large number of package versions, the packages bundled with AutoFixture might not contain the latest features of your mocking library.<br />
123-
> Make sure to install the latest version of the mocking library package, alongside the AutoFixture package.
124-
125143
### Testing frameworks
126144

127145
AutoFixture offers integrations with most major .NET testing frameworks.<br />
@@ -139,41 +157,14 @@ These integrations enable auto-generation of test cases, combining auto-generate
139157

140158
You can check the compatibility with your target framework version on the [wiki](https://github.com/AutoFixture/AutoFixture/wiki#net-platforms-compatibility-table) or on the [NuGet](https://www.nuget.org/profiles/AutoFixture) website.
141159

142-
### vNext feed
143-
144-
The artifacts of the next major version are published to [nuget.org](https://www.nuget.org), and are marked with the `preview` suffix (e.g. `5.0.0-preview00007`).</br>
145-
You can use these packages to early access and test the next major version of the AutoFixture.</br>
146-
Make sure to enable the preview packages in your IDE in order to see the latest version.
147-
148-
> __NOTE:__ This preview versions exists for the _preview purpose_ only, so use them with caution:
149-
>
150-
>* New versions of packages might contain breaking changes and API could change drastically from package to package. By other words, we don't follow the SemVer policy for the packages in this feed;
151-
>* Preview packages might be unlisted over time, in order to not clutter the version suggestion dialog in IDEs, but will generally remain available
152-
153-
## Documentation
154-
155-
* [CheatSheet](https://github.com/AutoFixture/AutoFixture/wiki/Cheat-Sheet)
156-
* [FAQ](https://github.com/AutoFixture/AutoFixture/wiki/FAQ)
157-
158-
### Additional resources
159-
160-
* [Pluralsight course](https://www.pluralsight.com/courses/unit-testing-autofixture-dot-net)
161-
* [ploeh blog](http://blog.ploeh.dk/tags/#AutoFixture-ref)
162-
* [Nikos Baxevanis' blog](http://blog.nikosbaxevanis.com)
163-
* [Enrico Campidoglio's blog](http://megakemp.com/tag/autofixture)
164-
* [Gert Jansen van Rensburg's blog](http://gertjvr.wordpress.com/category/autofixture)
165-
* [Questions on Stack Overflow](http://stackoverflow.com/questions/tagged/autofixture)
166-
167-
## Feedback & Questions
168-
169-
If you have questions, feel free to ask. The best places to ask are:
160+
## Contributing
170161

171-
* [Stack Overflow - use the *autofixture* tag](http://stackoverflow.com/questions/tagged/autofixture)
172-
* [GitHub Q&A Discussions](https://github.com/AutoFixture/AutoFixture/discussions/categories/q-a)
162+
Contributions to `AutoFixture.NUnit2` are welcome!
163+
If you would like to contribute, please review our [contributing guidelines](https://github.com/AutoFixture/AutoFixture.NUnit2/blob/master/CONTRIBUTING.md) and open an issue or pull request.
173164

174165
## License
175166

176-
AutoFixture is Open Source software and is released under the [MIT license](https://raw.githubusercontent.com/AutoFixture/AutoFixture/master/LICENCE.txt).<br />
167+
AutoFixture is Open Source software and is released under the [MIT license](https://raw.githubusercontent.com/AutoFixture/AutoFixture.NUnit2/master/LICENCE.txt).<br />
177168
The licenses allows the use of AutoFixture libraries in free and commercial applications and libraries without restrictions.
178169

179170
### .NET Foundation

Src/AutoFixture.NUnit2.UnitTest/AutoFixture.NUnit2.UnitTest.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
<Import Project="..\..\Common.Test.props" />
44

55
<PropertyGroup>
6-
<TargetFramework>net462</TargetFramework>
6+
<TargetFrameworks>net452;net462</TargetFrameworks>
77
<AssemblyTitle>AutoFixture.NUnit2.UnitTest</AssemblyTitle>
88
<AssemblyName>AutoFixture.NUnit2.UnitTest</AssemblyName>
99
<RootNamespace>AutoFixture.NUnit2.UnitTest</RootNamespace>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="AutoFixture" Version="4.18.1" />
1314
<PackageReference Include="nunit" Version="2.7.1" />
1415
<PackageReference Include="NUnitTestAdapter" Version="2.3.0" />
1516
<PackageReference Include="NUnitV2.Core" Version="2.7.1" />
1617
</ItemGroup>
1718

1819
<ItemGroup>
1920
<ProjectReference Include="..\AutoFixture.NUnit2\AutoFixture.NUnit2.csproj" />
20-
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
2121
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
2222
</ItemGroup>
2323

Src/AutoFixture.NUnit2/AutoFixture.NUnit2.csproj

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\Common.props" />
33

44
<PropertyGroup>
5-
<TargetFramework>net462</TargetFramework>
5+
<TargetFrameworks>net452;net462</TargetFrameworks>
66
<AssemblyTitle>AutoFixture.NUnit2</AssemblyTitle>
77
<AssemblyName>AutoFixture.NUnit2</AssemblyName>
88
<RootNamespace>AutoFixture.NUnit2</RootNamespace>
@@ -14,10 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
18-
</ItemGroup>
19-
20-
<ItemGroup>
17+
<PackageReference Include="AutoFixture" Version="4.18.1" />
2118
<!-- Isn't actually needed by this library, but is present as a NuGet guard to prevent installation of this package
2219
together with NUnit3 and higher. -->
2320
<PackageReference Include="NUnit" Version="[2.7.1,3.0.0)" />
@@ -26,10 +23,6 @@
2623

2724
<!-- Include additional files to NuGet package -->
2825
<ItemGroup>
29-
<Content Include="Readme.txt">
30-
<Pack>true</Pack>
31-
<PackagePath>readme.txt</PackagePath>
32-
</Content>
3326

3427
<Content Include="LocalAddin.cs.pp">
3528
<Pack>true</Pack>

Src/AutoFixture.NUnit2/Readme.txt

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

Src/TestTypeFoundation/TestTypeFoundation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\..\Common.Test.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>net462;netstandard2.0;net5.0;net6.0</TargetFrameworks>
6+
<TargetFrameworks>net452;net462;netstandard2.0</TargetFrameworks>
77
<AssemblyTitle>TestTypeFoundation</AssemblyTitle>
88
<AssemblyName>TestTypeFoundation</AssemblyName>
99
</PropertyGroup>

build/_build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace></RootNamespace>
77
<NoWarn>CS0649;CS0169</NoWarn>
88
<NukeRootDirectory>..</NukeRootDirectory>

0 commit comments

Comments
 (0)