Skip to content

Commit 48af207

Browse files
committed
Updated projects after migration
1 parent 1ad03a2 commit 48af207

File tree

6 files changed

+118
-370
lines changed

6 files changed

+118
-370
lines changed

AutoFixture.sln

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

Common.Test.xUnit3.props

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

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.xUnit3</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: 104 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,142 @@
1-
# AutoFixture
1+
# AutoFixture.xUnit3
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.xUnit3/master/LICENCE.txt)
4+
[![NuGet version](https://img.shields.io/nuget/v/AutoFixture.xUnit3?logo=nuget)](https://www.nuget.org/packages/AutoFixture.xUnit3)
5+
[![NuGet preview version](https://img.shields.io/nuget/vpre/AutoFixture.xUnit3?logo=nuget)](https://www.nuget.org/packages/AutoFixture.xUnit3)
6+
[![NuGet downloads](https://img.shields.io/nuget/dt/AutoFixture.xUnit3)](https://www.nuget.org/packages/AutoFixture.xUnit3)
117

12-
Write maintainable unit tests, faster.
13-
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.
8+
[AutoFixture.xUnit3](https://github.com/AutoFixture/AutoFixture.xUnit3) is a .NET library that integrates [AutoFixture](https://github.com/AutoFixture/AutoFixture) with xUnit 3.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.
1710

1811
## Table of Contents
1912

20-
- [Overview](#overview)
21-
- [Downloads](#downloads)
22-
- [Documentation](#documentation)
23-
- [Feedback & Questions](#feedback--questions)
13+
- [Installation](#installation)
14+
- [Getting Started](#getting-started)
15+
- [Integrations](#integrations)
16+
- [Contributing](#contributing)
2417
- [License](#license)
2518

26-
## Overview
19+
## Installation
20+
21+
AutoFixture packages are distributed via NuGet.<br />
22+
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.
23+
24+
```cmd
25+
dotnet add package AutoFixture.xUnit3 --version x.x.x
26+
```
27+
28+
```xml
29+
<PackageReference Include="AutoFixture.xUnit3" Version="x.x.x" />
30+
```
2731

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.)
32+
## Getting Started
2933

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.
34+
### Basic Usage
3135

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.
36+
`AutoFixture.xUnit3` provides an `[AutoData]` attribute that automatically populates test method parameters with generated data.
3337

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:
38+
For example, imagine you have a simple calculator class:
3539

3640
```c#
37-
[Fact]
38-
public void IntroductoryTest()
41+
public class Calculator
3942
{
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);
43+
public int Add(int a, int b) => a + b;
4944
}
5045
```
5146

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.
53-
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).
55-
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:
57-
58-
### [xUnit](http://blog.ploeh.dk/2010/10/08/AutoDataTheoriesWithAutoFixture.aspx)
47+
You can write a test using AutoFixture to provide the input values:
5948

6049
```c#
61-
[Theory, AutoData]
62-
public void IntroductoryTest(int expectedNumber, MyClass sut)
50+
using Xunit;
51+
using AutoFixture.Xunit3;
52+
53+
public class CalculatorTests
6354
{
64-
int result = sut.Echo(expectedNumber);
65-
Assert.Equal(expectedNumber, result);
55+
[Theory, AutoData]
56+
public void Add_SimpleValues_ReturnsCorrectResult(
57+
Calculator calculator, int a, int b)
58+
{
59+
// Act
60+
int result = calculator.Add(a, b);
61+
62+
// Assert
63+
Assert.AreEqual(a + b, result);
64+
}
6665
}
6766
```
6867

69-
### [NUnit](http://gertjvr.wordpress.com/2013/09/25/howto-autofixture-nunit2)
68+
### Inline Auto-Data
69+
70+
You can also combine auto-generated data with inline arguments using the `[InlineAutoData]` attribute.
71+
This allows you to specify some parameters while still letting AutoFixture generate the rest.
7072

7173
```c#
72-
[Test, AutoData]
73-
public void IntroductoryTest(int expectedNumber, MyClass sut)
74+
using Xunit;
75+
using AutoFixture.Xunit3;
76+
using AutoFixture;
77+
78+
public class CalculatorTests
7479
{
75-
int result = sut.Echo(expectedNumber);
76-
Assert.Equal(expectedNumber, result);
80+
[Theory, InlineAutoData(5, 8)]
81+
public void Add_SpecificValues_ReturnsCorrectResult(
82+
int a, int b, Calculator calculator)
83+
{
84+
// Act
85+
int result = calculator.Add(a, b);
86+
87+
// Assert
88+
Assert.AreEqual(13, result);
89+
}
7790
}
7891
```
7992

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.
93+
### Freezing Dependencies
8194

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

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

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.
99+
```c#
100+
public class Dependency { }
88101

89-
```cmd
90-
dotnet add package AutoFixture --version 4.18.0
102+
public class Consumer
103+
{
104+
public Dependency Dependency { get; }
105+
106+
public Consumer(Dependency dependency)
107+
{
108+
Dependency = dependency;
109+
}
110+
}
91111
```
92112

93-
```xml
94-
<PackageReference Include="AutoFixture" Version="4.18.0" />
113+
You can freeze the Dependency so that all requests for it within the test will return the same instance:
114+
115+
```c#
116+
using Xunit;
117+
using AutoFixture.Xunit3;
118+
using AutoFixture;
119+
120+
public class ConsumerTests
121+
{
122+
[Theory, AutoData]
123+
public void Consumer_UsesSameDependency(
124+
[Frozen] Dependency dependency, Consumer consumer)
125+
{
126+
// Assert
127+
Assert.AreSame(dependency, consumer.Dependency);
128+
}
129+
}
95130
```
96131

132+
## Integrations
133+
97134
AutoFixture offers a variety of utility packages and integrations with most of the major mocking libraries and testing frameworks.
98135

136+
> [!NOTE]
137+
> 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 />
138+
> Make sure to install the latest version of the integrated library package, alongside the AutoFixture packages.
139+
99140
### Core packages
100141

101142
The core packages offer the full set of AutoFixture's features without requring any testing framework or third party integration.
@@ -118,10 +159,6 @@ These integrations enable such features as configuring mocks, auto-injecting moc
118159
| 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) |
119160
| 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) |
120161

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-
125162
### Testing frameworks
126163

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

140177
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.
141178

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:
179+
## Contributing
170180

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)
181+
Contributions are welcome!<br />
182+
If you would like to contribute, please review our [contributing guidelines](https://github.com/AutoFixture/AutoFixture.xUnit3/blob/maste/CONTRIBUTING.md) and open an issue or pull request.
173183

174184
## License
175185

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

179189
### .NET Foundation

Src/AutoFixture.xUnit3.UnitTest/AutoFixture.xUnit3.UnitTest.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<Import Project="..\..\Common.props" />
44
<Import Project="..\..\Common.Test.props" />
5-
<Import Project="..\..\Common.Test.xUnit3.props" />
65

76
<PropertyGroup>
87
<TargetFrameworks>net48;net6.0</TargetFrameworks>
@@ -11,20 +10,27 @@
1110
<RootNamespace>AutoFixture.Xunit3.UnitTest</RootNamespace>
1211
</PropertyGroup>
1312

13+
<ItemGroup>
14+
<PackageReference Include="AutoFixture" Version="4.18.1" />
15+
<PackageReference Include="xunit.v3" Version="1.0.1" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
1422
<Choose>
1523
<When Condition="'$(TargetFramework)' == 'net48'">
1624
<PropertyGroup>
1725
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
1826
</PropertyGroup>
1927
<ItemGroup>
20-
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
2128
<ProjectReference Include="..\AutoFixture.xUnit3\AutoFixture.xUnit3.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
2229
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
2330
</ItemGroup>
2431
</When>
2532
<Otherwise>
2633
<ItemGroup>
27-
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
2834
<ProjectReference Include="..\AutoFixture.xUnit3\AutoFixture.xUnit3.csproj" />
2935
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
3036
</ItemGroup>

Src/AutoFixture.xUnit3/AutoFixture.xUnit3.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17+
<PackageReference Include="AutoFixture" Version="4.18.1" />
1718
<PackageReference Include="xunit.v3.extensibility.core" Version="1.0.0" />
1819
</ItemGroup>
1920

20-
<ItemGroup>
21-
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
22-
</ItemGroup>
2321
</Project>

0 commit comments

Comments
 (0)