diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5996f658a..12963ef30 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,12 +9,9 @@ on:
permissions:
contents: read
-env:
- DOTNET_NOLOGO: true
-
jobs:
build:
- name: Build
+ name: Build, test and package
runs-on: ubuntu-latest
steps:
@@ -26,15 +23,15 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
- dotnet-version: 3.1.x
+ dotnet-version: 10.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4
- with:
- versionSpec: 6.x
- name: Calculate version
uses: gittools/actions/gitversion/execute@v4
- name: Build
- run: ./build.sh
+ env:
+ VERSION: ${{ env.GitVersion_SemVer }}
+ run: ./build.sh build
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index c6412fb7d..622a1f5dd 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -9,12 +9,9 @@ permissions:
contents: read
id-token: write
-env:
- DOTNET_NOLOGO: true
-
jobs:
build:
- name: Publish
+ name: Build and publish
runs-on: ubuntu-latest
steps:
@@ -32,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
- dotnet-version: 3.1.x
+ dotnet-version: 10.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4
@@ -44,5 +41,6 @@ jobs:
- name: Deploy
env:
+ VERSION: ${{ env.GitVersion_SemVer }}
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
run: ./build.sh publish
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 000000000..d74a4b724
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,37 @@
+# Machine.Specificaitons Agent Guide
+**Machine.Specifications** is also known as **MSpec**.
+
+## Project architecture
+All code for MSpec lives in `src` or `tests`. Documentation is in `docs`, and logos for NuGet are in `assets`.
+
+The below source projects are in use by this project, along with test projects. You should **ignore** any other project that is not referenced in the `.slnx` file in the repo root.
+
+- `Machine.Specifications` - Meta NuGet package that references the default set of dependencies
+- `Machine.Specifications.Analyzers` - Code hints and fixes for writing tests "the MSpec way"
+- `Machine.Specifications.Core` - Core testing engine and framwork
+- `Machine.Specifications.Core.SourceGenerator` - Source generators to aid in test discovery and speed up execution
+- `Machine.Specifications.Fakes` - Interface mocking library used by MSpec
+- `Machine.Specifications.Fakes.Analyzers` - Code warnings and fixes for writing mocks using MSpec
+- `Machine.Specifications.Fakes.SourceGenerator` - Source generator that creates code for mocks in MSpec
+- `Machine.Specifications.Should` - Assertion library for MSpec
+- `Machine.Specifications.Templates` - Dotnet 'new' templates for creating test projects using MSpec
+
+All test projects end in `.Specs`, and match the libraries above.
+
+**Important:** Any projects named with the words `Fixtures` or `Runner` should be ignored as these are legacy and will be removed.
+Only use the projects referenced by the `.slnx` file in the repo root.
+
+## Dev environment tips
+- Use `dotnet build` to build the solution
+- Use `dotnet test` to build and run all the tests in the solution
+
+## Making changes
+- Make the smallest, most surgical change you can make for the feature you are writing
+- Tests should be focused and not verbose
+- Follow the naming and styling conventions of this repository
+- All changes, in general, should have accompanying tests
+- Any API surface changes should have documentation added to `docs`
+
+## PR instructions
+- Title format: Use
with a brief description
+- Always run `dotnet test` before committing.
diff --git a/Directory.Build.props b/Directory.Build.props
index bb9a87f75..6cba54252 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,7 +1,6 @@
- netstandard2.0enableenablelatest
@@ -11,7 +10,7 @@
Machine Specificationstest;unit;testing;context;specification;bdd;tdd;mspechttps://github.com/machine/machine.specifications/releases
- icon.png
+ mspec_logo.pnghttp://github.com/machine/machine.specificationshttp://github.com/machine/machine.specificationsgit
@@ -20,8 +19,8 @@
-
-
+
+
diff --git a/Machine.Specifications.slnx b/Machine.Specifications.slnx
index 7e57ad360..870951541 100644
--- a/Machine.Specifications.slnx
+++ b/Machine.Specifications.slnx
@@ -1,15 +1,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/assets/mspec_logo.png b/assets/mspec_logo.png
new file mode 100644
index 000000000..41082cd30
Binary files /dev/null and b/assets/mspec_logo.png differ
diff --git a/assets/mspec_logo.svg b/assets/mspec_logo.svg
new file mode 100644
index 000000000..993a93814
--- /dev/null
+++ b/assets/mspec_logo.svg
@@ -0,0 +1,27 @@
+
+
+
diff --git a/build.ps1 b/build.ps1
index 603c8f435..53e55af94 100644
--- a/build.ps1
+++ b/build.ps1
@@ -10,7 +10,7 @@ if ($null -eq (Get-Command "dotnet" -ErrorAction Ignore)) {
Push-Location (Split-Path $MyInvocation.MyCommand.Definition)
try {
- & dotnet run ./build/build.cs -- $args
+ & dotnet ./build/build.cs -- $args
}
finally {
Pop-Location
diff --git a/build.sh b/build.sh
index 7e6904a8d..e1e918593 100755
--- a/build.sh
+++ b/build.sh
@@ -3,7 +3,7 @@
set -euo pipefail
if which dotnet > /dev/null; then
- dotnet run ./build/build.cs -- "$@"
+ dotnet ./build/build.cs -- "$@"
else
echo "error(1): Could not find 'dotnet', please install .NET SDK"
exit 1
diff --git a/build/build.cs b/build/build.cs
index 2c6b19f34..6e0d29a82 100644
--- a/build/build.cs
+++ b/build/build.cs
@@ -4,7 +4,7 @@
using static Bullseye.Targets;
using static SimpleExec.Command;
-var version = new GitVersion();
+var version = default(string);
Target("clean", () =>
{
@@ -16,20 +16,19 @@
}
});
+Target("version", () =>
+{
+ version = Environment.GetEnvironmentVariable("VERSION");
+});
+
Target("restore", dependsOn: ["clean"], () =>
{
Run("dotnet", "restore");
});
-Target("build", dependsOn: ["restore"], () =>
+Target("build", dependsOn: ["restore", "version"], () =>
{
- Run("dotnet", "build " +
- "--no-restore " +
- "--configuration Release " +
- $"--property Version={version.SemVer} " +
- $"--property AssemblyVersion={version.AssemblySemVer} " +
- $"--property FileVersion={version.AssemblySemFileVer} " +
- $"--property InformationalVersion={version.InformationalVersion}");
+ Run("dotnet", $"build --configuration Release --no-restore --property Version={version}");
});
Target("test", dependsOn: ["build"], () =>
@@ -37,29 +36,18 @@
Run("dotnet", "test --configuration Release --no-restore --no-build");
});
-Target("package", dependsOn: ["build", "test"], () =>
+Target("package", dependsOn: ["build", "test", "version"], () =>
{
- Run("dotnet", $"pack --configuration Release --no-restore --no-build --output artifacts --property Version={version.SemVer}");
+ Run("dotnet", $"pack --configuration Release --no-restore --no-build --output artifacts --property Version={version}");
});
Target("publish", dependsOn: ["package"], () =>
{
var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY");
- Run("dotnet", $"nuget push {Path.Combine("artifacts", "*.nupkg")} --api-key {apiKey} --source https://api.nuget.org/v3/index.json");
+ Run("dotnet", $"nuget push artifacts/*.nupkg --api-key {apiKey} --source https://api.nuget.org/v3/index.json");
});
Target("default", dependsOn: ["package"]);
await RunTargetsAndExitAsync(args);
-
-public class GitVersion
-{
- public string SemVer { get; } = Environment.GetEnvironmentVariable("GitVersion_SemVer") ?? "0.1.0";
-
- public string AssemblySemVer { get; } = Environment.GetEnvironmentVariable("GitVersion_AssemblySemVer") ?? "0.1.0";
-
- public string AssemblySemFileVer { get; } = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "0.1.0";
-
- public string InformationalVersion { get; } = Environment.GetEnvironmentVariable("GitVersion_InformationalVersion") ?? "0.1.0";
-}
diff --git a/docs/.gitkeep b/docs/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/global.json b/global.json
new file mode 100644
index 000000000..3140116df
--- /dev/null
+++ b/global.json
@@ -0,0 +1,5 @@
+{
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ }
+}
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 000000000..c6ef25973
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,9 @@
+
+
+
+
+
+ netstandard2.0
+
+
+
diff --git a/src/Machine.Specifications.Analyzers.Tests/Machine.Specifications.Analyzers.Tests.csproj b/src/Machine.Specifications.Analyzers.Tests/Machine.Specifications.Analyzers.Tests.csproj
deleted file mode 100644
index 7047e919d..000000000
--- a/src/Machine.Specifications.Analyzers.Tests/Machine.Specifications.Analyzers.Tests.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- net10.0
- Exe
- true
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Analyzers/Machine.Specifications.Analyzers.csproj b/src/Machine.Specifications.Analyzers/Machine.Specifications.Analyzers.csproj
index ecefb21de..9a511ee01 100644
--- a/src/Machine.Specifications.Analyzers/Machine.Specifications.Analyzers.csproj
+++ b/src/Machine.Specifications.Analyzers/Machine.Specifications.Analyzers.csproj
@@ -4,7 +4,6 @@
falsetruetrue
- $(TargetsForTfmSpecificContentInPackage);PackageItems
@@ -12,17 +11,11 @@
-
+
-
+
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Analyzers/MachineSpecStubs.cs b/src/Machine.Specifications.Analyzers/MachineSpecStubs.cs
index 1affc07dc..8b7093163 100644
--- a/src/Machine.Specifications.Analyzers/MachineSpecStubs.cs
+++ b/src/Machine.Specifications.Analyzers/MachineSpecStubs.cs
@@ -1,4 +1,4 @@
-namespace Machine.Specifications;
+namespace Machine.Specifications;
public class SetupDelegateAttribute : Attribute
{
diff --git a/src/Machine.Specifications.Analyzers/install.ps1 b/src/Machine.Specifications.Analyzers/install.ps1
deleted file mode 100644
index ff051759d..000000000
--- a/src/Machine.Specifications.Analyzers/install.ps1
+++ /dev/null
@@ -1,58 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if($project.Object.SupportsPackageDependencyResolution)
-{
- if($project.Object.SupportsPackageDependencyResolution())
- {
- # Do not install analyzers via install.ps1, instead let the project system handle it.
- return
- }
-}
-
-$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve
-
-foreach($analyzersPath in $analyzersPaths)
-{
- if (Test-Path $analyzersPath)
- {
- # Install the language agnostic analyzers.
- foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
- }
- }
- }
-}
-
-# $project.Type gives the language name like (C# or VB.NET)
-$languageFolder = ""
-if($project.Type -eq "C#")
-{
- $languageFolder = "cs"
-}
-if($project.Type -eq "VB.NET")
-{
- $languageFolder = "vb"
-}
-if($languageFolder -eq "")
-{
- return
-}
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Install language specific analyzers.
- $languageAnalyzersPath = join-path $analyzersPath $languageFolder
- if (Test-Path $languageAnalyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
- }
- }
- }
-}
diff --git a/src/Machine.Specifications.Analyzers/uninstall.ps1 b/src/Machine.Specifications.Analyzers/uninstall.ps1
deleted file mode 100644
index 4bed33374..000000000
--- a/src/Machine.Specifications.Analyzers/uninstall.ps1
+++ /dev/null
@@ -1,65 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if($project.Object.SupportsPackageDependencyResolution)
-{
- if($project.Object.SupportsPackageDependencyResolution())
- {
- # Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it.
- return
- }
-}
-
-$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Uninstall the language agnostic analyzers.
- if (Test-Path $analyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
- }
- }
- }
-}
-
-# $project.Type gives the language name like (C# or VB.NET)
-$languageFolder = ""
-if($project.Type -eq "C#")
-{
- $languageFolder = "cs"
-}
-if($project.Type -eq "VB.NET")
-{
- $languageFolder = "vb"
-}
-if($languageFolder -eq "")
-{
- return
-}
-
-foreach($analyzersPath in $analyzersPaths)
-{
- # Uninstall language specific analyzers.
- $languageAnalyzersPath = join-path $analyzersPath $languageFolder
- if (Test-Path $languageAnalyzersPath)
- {
- foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll)
- {
- if($project.Object.AnalyzerReferences)
- {
- try
- {
- $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
- }
- catch
- {
-
- }
- }
- }
- }
-}
diff --git a/src/Machine.Specifications.Core.SourceGenerator/Machine.Specifications.Core.SourceGenerator.csproj b/src/Machine.Specifications.Core.SourceGenerator/Machine.Specifications.Core.SourceGenerator.csproj
new file mode 100644
index 000000000..3a421494b
--- /dev/null
+++ b/src/Machine.Specifications.Core.SourceGenerator/Machine.Specifications.Core.SourceGenerator.csproj
@@ -0,0 +1,9 @@
+
+
+
+ true
+ false
+ true
+
+
+
diff --git a/src/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj b/src/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj
deleted file mode 100644
index 80c9588be..000000000
--- a/src/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- net10.0
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Core/Framework.cs b/src/Machine.Specifications.Core/Framework.cs
index 60ea270f3..f8338ad61 100644
--- a/src/Machine.Specifications.Core/Framework.cs
+++ b/src/Machine.Specifications.Core/Framework.cs
@@ -1,3 +1,5 @@
+using System.Linq.Expressions;
+
namespace Machine.Specifications
{
[SetupDelegate]
diff --git a/src/Machine.Specifications.Core/Machine.Specifications.Core.csproj b/src/Machine.Specifications.Core/Machine.Specifications.Core.csproj
index e06333496..483bc167c 100644
--- a/src/Machine.Specifications.Core/Machine.Specifications.Core.csproj
+++ b/src/Machine.Specifications.Core/Machine.Specifications.Core.csproj
@@ -9,7 +9,15 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/src/Machine.Specifications.Core/Runner/Impl/DefaultRunner.cs b/src/Machine.Specifications.Core/Runner/Impl/DefaultRunner.cs
index a2a283701..7de7d5da9 100644
--- a/src/Machine.Specifications.Core/Runner/Impl/DefaultRunner.cs
+++ b/src/Machine.Specifications.Core/Runner/Impl/DefaultRunner.cs
@@ -3,7 +3,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
#endif
@@ -16,11 +16,11 @@
namespace Machine.Specifications.Runner.Impl
{
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
[Serializable]
#endif
public class DefaultRunner :
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
MarshalByRefObject, IMessageSink,
#endif
ISpecificationRunner
@@ -40,7 +40,7 @@ public class DefaultRunner :
private bool explicitStartAndEnd;
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
public DefaultRunner(object listener, string runOptionsXml, bool signalRunStartAndEnd)
: this(new RemoteRunListenerDecorator(listener), RunOptions.Parse(runOptionsXml), signalRunStartAndEnd)
{
@@ -173,7 +173,7 @@ public void EndRun(Assembly assembly)
runEnd.Invoke();
}
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
[SecurityCritical]
public override object InitializeLifetimeService()
{
diff --git a/src/Machine.Specifications.Core/Runner/Impl/RemoteRunListenerDecorator.cs b/src/Machine.Specifications.Core/Runner/Impl/RemoteRunListenerDecorator.cs
index 7cd8b8d01..f7ac685b9 100644
--- a/src/Machine.Specifications.Core/Runner/Impl/RemoteRunListenerDecorator.cs
+++ b/src/Machine.Specifications.Core/Runner/Impl/RemoteRunListenerDecorator.cs
@@ -1,4 +1,4 @@
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Machine.Specifications.Core/Sdk/RemoteRunListenerDecorator.cs b/src/Machine.Specifications.Core/Sdk/RemoteRunListenerDecorator.cs
index b8c84f915..93eb8ca36 100644
--- a/src/Machine.Specifications.Core/Sdk/RemoteRunListenerDecorator.cs
+++ b/src/Machine.Specifications.Core/Sdk/RemoteRunListenerDecorator.cs
@@ -1,4 +1,4 @@
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
using System;
using System.Collections;
diff --git a/src/Machine.Specifications.Core/Sdk/RunSpecs.cs b/src/Machine.Specifications.Core/Sdk/RunSpecs.cs
index 21c300993..e5ca4c9d6 100644
--- a/src/Machine.Specifications.Core/Sdk/RunSpecs.cs
+++ b/src/Machine.Specifications.Core/Sdk/RunSpecs.cs
@@ -1,4 +1,4 @@
-#if !NET6_0_OR_GREATER
+#if !NETSTANDARD
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Machine.Specifications.Fakes.Analyzers/Machine.Specifications.Fakes.Analyzers.csproj b/src/Machine.Specifications.Fakes.Analyzers/Machine.Specifications.Fakes.Analyzers.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/src/Machine.Specifications.Fakes.Analyzers/Machine.Specifications.Fakes.Analyzers.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/src/Machine.Specifications.Fakes.SourceGenerator/Machine.Specifications.Fakes.SourceGenerator.csproj b/src/Machine.Specifications.Fakes.SourceGenerator/Machine.Specifications.Fakes.SourceGenerator.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/src/Machine.Specifications.Fakes.SourceGenerator/Machine.Specifications.Fakes.SourceGenerator.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/src/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj b/src/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj
deleted file mode 100644
index ba4c133d1..000000000
--- a/src/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- net10.0
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Fakes/Machine.Specifications.Fakes.csproj b/src/Machine.Specifications.Fakes/Machine.Specifications.Fakes.csproj
index cc67fc1c0..b33e0d1b2 100644
--- a/src/Machine.Specifications.Fakes/Machine.Specifications.Fakes.csproj
+++ b/src/Machine.Specifications.Fakes/Machine.Specifications.Fakes.csproj
@@ -1,9 +1,5 @@
-
- false
-
-
diff --git a/src/Machine.Specifications.Interfaces/Machine.Specifications.Interfaces.csproj b/src/Machine.Specifications.Interfaces/Machine.Specifications.Interfaces.csproj
deleted file mode 100644
index f63243811..000000000
--- a/src/Machine.Specifications.Interfaces/Machine.Specifications.Interfaces.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- netstandard2.0
- Machine.Specifications
-
- SDK and common runner interfaces used by Machine.Specifications
- Machine Specifications
- test;unit;testing;context;specification;bdd;tdd;mspec
- https://github.com/machine/machine.specifications/releases
- icon.png
- http://github.com/machine/machine.specifications
- MIT
-
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Runner.Utility.Specs/Machine.Specifications.Runner.Utility.Specs.csproj b/src/Machine.Specifications.Runner.Utility.Specs/Machine.Specifications.Runner.Utility.Specs.csproj
deleted file mode 100644
index 73c3fc6d9..000000000
--- a/src/Machine.Specifications.Runner.Utility.Specs/Machine.Specifications.Runner.Utility.Specs.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- net10.0
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Machine.Specifications.Should/Machine.Specifications.Should.csproj b/src/Machine.Specifications.Should/Machine.Specifications.Should.csproj
index 9b9b8ea5e..5e7f57426 100644
--- a/src/Machine.Specifications.Should/Machine.Specifications.Should.csproj
+++ b/src/Machine.Specifications.Should/Machine.Specifications.Should.csproj
@@ -1,5 +1,9 @@
+
+ Machine.Specifications
+
+
Assertion library for Machine.Specifications
diff --git a/src/Machine.Specifications.Templates/Machine.Specifications.Templates.csproj b/src/Machine.Specifications.Templates/Machine.Specifications.Templates.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/src/Machine.Specifications.Templates/Machine.Specifications.Templates.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
new file mode 100644
index 000000000..839a65f1b
--- /dev/null
+++ b/tests/Directory.Build.props
@@ -0,0 +1,10 @@
+
+
+
+
+
+ net10.0
+ false
+
+
+
diff --git a/src/Machine.Specifications.Analyzers.Tests/AnalyzerVerifier.cs b/tests/Machine.Specifications.Analyzers.Specs/AnalyzerVerifier.cs
similarity index 100%
rename from src/Machine.Specifications.Analyzers.Tests/AnalyzerVerifier.cs
rename to tests/Machine.Specifications.Analyzers.Specs/AnalyzerVerifier.cs
diff --git a/src/Machine.Specifications.Analyzers.Tests/CodeFixVerifier.cs b/tests/Machine.Specifications.Analyzers.Specs/CodeFixVerifier.cs
similarity index 100%
rename from src/Machine.Specifications.Analyzers.Tests/CodeFixVerifier.cs
rename to tests/Machine.Specifications.Analyzers.Specs/CodeFixVerifier.cs
diff --git a/tests/Machine.Specifications.Analyzers.Specs/Machine.Specifications.Analyzers.Specs.csproj b/tests/Machine.Specifications.Analyzers.Specs/Machine.Specifications.Analyzers.Specs.csproj
new file mode 100644
index 000000000..b43d47fba
--- /dev/null
+++ b/tests/Machine.Specifications.Analyzers.Specs/Machine.Specifications.Analyzers.Specs.csproj
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Machine.Specifications.Analyzers.Tests/Maintainability/AccessModifierShouldNotBeUsedTests.cs b/tests/Machine.Specifications.Analyzers.Specs/Maintainability/AccessModifierShouldNotBeUsedTests.cs
similarity index 72%
rename from src/Machine.Specifications.Analyzers.Tests/Maintainability/AccessModifierShouldNotBeUsedTests.cs
rename to tests/Machine.Specifications.Analyzers.Specs/Maintainability/AccessModifierShouldNotBeUsedTests.cs
index 275b80c2c..8fc49bf73 100644
--- a/src/Machine.Specifications.Analyzers.Tests/Maintainability/AccessModifierShouldNotBeUsedTests.cs
+++ b/tests/Machine.Specifications.Analyzers.Specs/Maintainability/AccessModifierShouldNotBeUsedTests.cs
@@ -1,5 +1,6 @@
-using System.Threading.Tasks;
-using Xunit;
+using System.Threading.Tasks;
+using Machine.Specifications.Analyzers.Naming;
+using Microsoft.CodeAnalysis.Testing;
using Verify = Machine.Specifications.Analyzers.Tests.CodeFixVerifier<
Machine.Specifications.Analyzers.Maintainability.AccessModifierShouldNotBeUsedAnalyzer,
Machine.Specifications.Analyzers.Maintainability.AccessModifierShouldNotBeUsedCodeFixProvider>;
@@ -8,8 +9,7 @@ namespace Machine.Specifications.Analyzers.Tests.Maintainability;
public class AccessModifierShouldNotBeUsedTests
{
- [Fact]
- public async Task NoErrorsInValidSource()
+ public class NoErrorsInValidSource
{
const string source = @"
using System;
@@ -31,12 +31,11 @@ class inner_specs
}
}
}";
-
- await Verify.VerifyAnalyzerAsync(source);
+ It should_verify = async () =>
+ await Verify.VerifyAnalyzerAsync(source);
}
- [Fact]
- public async Task RemovesClassAccessModifier()
+ public class RemovesClassAccessModifier()
{
const string source = @"
using System;
@@ -64,15 +63,18 @@ class SpecsClass
}
}";
- var expected = Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
- .WithLocation(0)
- .WithArguments("SpecsClass");
+ static DiagnosticResult expected;
+
+ Because of = () =>
+ expected = Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
+ .WithLocation(0)
+ .WithArguments("SpecsClass");
- await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
}
- [Fact]
- public async Task RemovesFieldAccessModifier()
+ public class RemovesFieldAccessModifier
{
const string source = @"
using System;
@@ -100,15 +102,18 @@ class SpecsClass
}
}";
- var expected = Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
- .WithLocation(0)
- .WithArguments("should_do_something");
+ static DiagnosticResult expected;
+
+ Because of = () =>
+ expected = Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
+ .WithLocation(0)
+ .WithArguments("should_do_something");
- await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
}
- [Fact]
- public async Task RemovesFieldAndClassAccessModifiers()
+ public class RemovesFieldAndClassAccessModifiers
{
const string source = @"
using System;
@@ -136,8 +141,10 @@ class SpecsClass
}
}";
- var expected = new[]
- {
+ static DiagnosticResult[] expected;
+
+ Because of = () => expected =
+ [
Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
.WithLocation(0)
.WithArguments("SpecsClass"),
@@ -145,13 +152,13 @@ class SpecsClass
Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
.WithLocation(1)
.WithArguments("should_do_something")
- };
+ ];
- await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
}
- [Fact]
- public async Task RemovesInnerFieldAndClassAccessModifiers()
+ public class RemovesInnerFieldAndClassAccessModifiers
{
const string source = @"
using System;
@@ -195,8 +202,10 @@ class InnerClass
}
}";
- var expected = new[]
- {
+ static DiagnosticResult[] expected;
+
+ Because of = () => expected =
+ [
Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
.WithLocation(0)
.WithArguments("value"),
@@ -208,13 +217,13 @@ class InnerClass
Verify.Diagnostic(DiagnosticIds.Maintainability.AccessModifierShouldNotBeUsed)
.WithLocation(2)
.WithArguments("context")
- };
+ ];
- await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, expected, fixedSource);
}
- [Fact]
- public async Task RemovesFieldAccessModifierWithLeadingTrivia()
+ public class RemovesFieldAccessModifierWithLeadingTrivia
{
const string source = @"
using System;
@@ -246,11 +255,11 @@ class SpecsClass
}
}";
- await Verify.VerifyCodeFixAsync(source, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, fixedSource);
}
- [Fact]
- public async Task RemovesMultipleAccessModifiers()
+ public class RemovesMultipleAccessModifiers
{
const string source = @"
using System;
@@ -282,6 +291,7 @@ class SpecsClass
}
}";
- await Verify.VerifyCodeFixAsync(source, fixedSource);
+ It should_verify = async () =>
+ await Verify.VerifyCodeFixAsync(source, fixedSource);
}
}
diff --git a/src/Machine.Specifications.Analyzers.Tests/VerifierHelper.cs b/tests/Machine.Specifications.Analyzers.Specs/VerifierHelper.cs
similarity index 100%
rename from src/Machine.Specifications.Analyzers.Tests/VerifierHelper.cs
rename to tests/Machine.Specifications.Analyzers.Specs/VerifierHelper.cs
diff --git a/tests/Machine.Specifications.Core.SourceGenerator.Specs/Machine.Specifications.Core.SourceGenerator.Specs.csproj b/tests/Machine.Specifications.Core.SourceGenerator.Specs/Machine.Specifications.Core.SourceGenerator.Specs.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/tests/Machine.Specifications.Core.SourceGenerator.Specs/Machine.Specifications.Core.SourceGenerator.Specs.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/src/Machine.Specifications.Core.Specs/.editorconfig b/tests/Machine.Specifications.Core.Specs/.editorconfig
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/.editorconfig
rename to tests/Machine.Specifications.Core.Specs/.editorconfig
diff --git a/src/Machine.Specifications.Core.Specs/CatchSpecs.cs b/tests/Machine.Specifications.Core.Specs/CatchSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/CatchSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/CatchSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Controller/ControllerSpecs.cs b/tests/Machine.Specifications.Core.Specs/Controller/ControllerSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Controller/ControllerSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Controller/ControllerSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/ExceptionResultSpecs.cs b/tests/Machine.Specifications.Core.Specs/ExceptionResultSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/ExceptionResultSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/ExceptionResultSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Explorers/AssemblyExplorerSpecs.cs b/tests/Machine.Specifications.Core.Specs/Explorers/AssemblyExplorerSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Explorers/AssemblyExplorerSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Explorers/AssemblyExplorerSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Factories/ContextFactorySpecs.cs b/tests/Machine.Specifications.Core.Specs/Factories/ContextFactorySpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Factories/ContextFactorySpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Factories/ContextFactorySpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Factories/SpecificationFactorySpecs.cs b/tests/Machine.Specifications.Core.Specs/Factories/SpecificationFactorySpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Factories/SpecificationFactorySpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Factories/SpecificationFactorySpecs.cs
diff --git a/src/Machine.Specifications.Fixtures/ExampleFixture.cs b/tests/Machine.Specifications.Core.Specs/Fixtures/ExampleFixture.cs
similarity index 100%
rename from src/Machine.Specifications.Fixtures/ExampleFixture.cs
rename to tests/Machine.Specifications.Core.Specs/Fixtures/ExampleFixture.cs
diff --git a/src/Machine.Specifications.Fixtures/FailingFixture.cs b/tests/Machine.Specifications.Core.Specs/Fixtures/FailingFixture.cs
similarity index 100%
rename from src/Machine.Specifications.Fixtures/FailingFixture.cs
rename to tests/Machine.Specifications.Core.Specs/Fixtures/FailingFixture.cs
diff --git a/src/Machine.Specifications.Fixtures/LargeFixture.cs b/tests/Machine.Specifications.Core.Specs/Fixtures/LargeFixture.cs
similarity index 100%
rename from src/Machine.Specifications.Fixtures/LargeFixture.cs
rename to tests/Machine.Specifications.Core.Specs/Fixtures/LargeFixture.cs
diff --git a/src/Machine.Specifications.Fixtures/RandomFixture.cs b/tests/Machine.Specifications.Core.Specs/Fixtures/RandomFixture.cs
similarity index 100%
rename from src/Machine.Specifications.Fixtures/RandomFixture.cs
rename to tests/Machine.Specifications.Core.Specs/Fixtures/RandomFixture.cs
diff --git a/tests/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj b/tests/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj
new file mode 100644
index 000000000..da11eb34c
--- /dev/null
+++ b/tests/Machine.Specifications.Core.Specs/Machine.Specifications.Core.Specs.csproj
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/Machine.Specifications.Core.Specs/Model/ContextSpecs.cs b/tests/Machine.Specifications.Core.Specs/Model/ContextSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Model/ContextSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Model/ContextSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Model/SpecificationSpecs.cs b/tests/Machine.Specifications.Core.Specs/Model/SpecificationSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Model/SpecificationSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Model/SpecificationSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Runner/AsyncDelegateRunnerSpecs.cs b/tests/Machine.Specifications.Core.Specs/Runner/AsyncDelegateRunnerSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Runner/AsyncDelegateRunnerSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Runner/AsyncDelegateRunnerSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerSpecs.cs b/tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithBehaviorSpecs.cs b/tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithBehaviorSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithBehaviorSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithBehaviorSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithInheritanceSpecs.cs b/tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithInheritanceSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithInheritanceSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Runner/SpecificationRunnerWithInheritanceSpecs.cs
diff --git a/src/Machine.Specifications.Core.Specs/Tags.cs b/tests/Machine.Specifications.Core.Specs/Tags.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Tags.cs
rename to tests/Machine.Specifications.Core.Specs/Tags.cs
diff --git a/src/Machine.Specifications.Core.Specs/Utility/Internal/NamingSpecs.cs b/tests/Machine.Specifications.Core.Specs/Utility/Internal/NamingSpecs.cs
similarity index 100%
rename from src/Machine.Specifications.Core.Specs/Utility/Internal/NamingSpecs.cs
rename to tests/Machine.Specifications.Core.Specs/Utility/Internal/NamingSpecs.cs
diff --git a/tests/Machine.Specifications.Fakes.Analzyers.Specs/Machine.Specifications.Fakes.Analzyers.Specs.csproj b/tests/Machine.Specifications.Fakes.Analzyers.Specs/Machine.Specifications.Fakes.Analzyers.Specs.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/tests/Machine.Specifications.Fakes.Analzyers.Specs/Machine.Specifications.Fakes.Analzyers.Specs.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/Machine.Specifications.Fakes.SourceGenerator.Specs/Machine.Specifications.Fakes.SourceGenerator.Specs.csproj b/tests/Machine.Specifications.Fakes.SourceGenerator.Specs/Machine.Specifications.Fakes.SourceGenerator.Specs.csproj
new file mode 100644
index 000000000..bef03830d
--- /dev/null
+++ b/tests/Machine.Specifications.Fakes.SourceGenerator.Specs/Machine.Specifications.Fakes.SourceGenerator.Specs.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/src/Machine.Specifications.Fakes.Specs/DeepFake.cs b/tests/Machine.Specifications.Fakes.Specs/DeepFake.cs
similarity index 100%
rename from src/Machine.Specifications.Fakes.Specs/DeepFake.cs
rename to tests/Machine.Specifications.Fakes.Specs/DeepFake.cs
diff --git a/tests/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj b/tests/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj
new file mode 100644
index 000000000..f25d703ea
--- /dev/null
+++ b/tests/Machine.Specifications.Fakes.Specs/Machine.Specifications.Fakes.Specs.csproj
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/Machine.Specifications.Fakes.Specs/TestSpec.cs b/tests/Machine.Specifications.Fakes.Specs/TestSpec.cs
similarity index 100%
rename from src/Machine.Specifications.Fakes.Specs/TestSpec.cs
rename to tests/Machine.Specifications.Fakes.Specs/TestSpec.cs
diff --git a/tests/Machine.Specifications.Fixtures/ExampleFixture.cs b/tests/Machine.Specifications.Fixtures/ExampleFixture.cs
new file mode 100644
index 000000000..a12f8a30a
--- /dev/null
+++ b/tests/Machine.Specifications.Fixtures/ExampleFixture.cs
@@ -0,0 +1,91 @@
+using System;
+using Machine.Specifications;
+
+namespace Example
+{
+ public class Account
+ {
+ public decimal Balance { get; set; }
+
+ public void Transfer(decimal amount, Account toAccount)
+ {
+ if (amount > Balance)
+ throw new Exception(String.Format("Cannot transfer ${ 0 }.The available balance is ${ 1}.", amount, Balance));
+
+ Balance -= amount;
+ toAccount.Balance += amount;
+ }
+ }
+
+ public class TestAssemblyContext : IAssemblyContext
+ {
+ public static bool OnAssemblyStartRun;
+
+ public static bool OnAssemblyCompleteRun;
+
+ public void OnAssemblyStart()
+ {
+ OnAssemblyStartRun = true;
+ }
+
+ public void OnAssemblyComplete()
+ {
+ OnAssemblyCompleteRun = true;
+ }
+ }
+
+ [Subject(typeof(Account), "Funds transfer")]
+ public class when_transferring_between_two_accounts : AccountSpecs
+ {
+ Establish context = () =>
+ {
+ fromAccount = new Account { Balance = 1m };
+ toAccount = new Account { Balance = 1m };
+ };
+
+ Because of = () =>
+ fromAccount.Transfer(1m, toAccount);
+
+ It should_debit_the_from_account_by_the_amount_transferred = () =>
+ fromAccount.Balance.ShouldEqual(0m);
+
+ It should_credit_the_to_account_by_the_amount_transferred = () =>
+ toAccount.Balance.ShouldEqual(2m);
+ }
+
+ [Subject(typeof(Account), "Funds transfer")]
+ [Tags("failure")]
+ public class when_transferring_an_amount_larger_than_the_balance_of_the_from_account : AccountSpecs
+ {
+ static Exception exception;
+
+ Establish context = () =>
+ {
+ fromAccount = new Account { Balance = 1m };
+ toAccount = new Account { Balance = 1m };
+ };
+
+ Because of = () =>
+ exception = Catch.Exception(() => fromAccount.Transfer(2m, toAccount));
+
+ It should_not_allow_the_transfer = () =>
+ exception.ShouldBeOfExactType();
+ }
+
+ public abstract class AccountSpecs
+ {
+ protected static Account fromAccount;
+
+ protected static Account toAccount;
+ }
+
+ [Subject("Recent Account Activity Summary page")]
+ public class when_a_customer_first_views_the_account_summary_page
+ {
+ It should_display_all_account_transactions_for_the_past_thirty_days;
+
+ It should_display_debit_amounts_in_red_text;
+
+ It should_display_deposit_amounts_in_black_text;
+ }
+}
diff --git a/tests/Machine.Specifications.Fixtures/FailingFixture.cs b/tests/Machine.Specifications.Fixtures/FailingFixture.cs
new file mode 100644
index 000000000..92b7a74d7
--- /dev/null
+++ b/tests/Machine.Specifications.Fixtures/FailingFixture.cs
@@ -0,0 +1,35 @@
+using System;
+using Machine.Specifications;
+
+namespace Example.Failing
+{
+ [Subject("Scott Bellware")]
+ public class at_any_given_moment
+ {
+ It will_fail = () =>
+ throw new Exception("hi scott, love you, miss you.");
+ }
+
+ [Tags("example")]
+ public class context_with_multiple_establish_clauses
+ {
+ Establish foo = () => { };
+
+ Establish bar = () => { };
+
+ It should = () => { };
+ }
+
+ [SetupDelegate]
+ public delegate void Given();
+
+ [Tags("example")]
+ public class context_with_multiple_given_clauses
+ {
+ Given foo = () => { };
+
+ Given bar = () => { };
+
+ It should = () => { };
+ }
+}
diff --git a/tests/Machine.Specifications.Fixtures/LargeFixture.cs b/tests/Machine.Specifications.Fixtures/LargeFixture.cs
new file mode 100644
index 000000000..1d2bf0ef2
--- /dev/null
+++ b/tests/Machine.Specifications.Fixtures/LargeFixture.cs
@@ -0,0 +1,1025 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Threading.Tasks;
+using Machine.Specifications;
+
+namespace Example.Large
+{
+ public class when_there_are_many_contexts
+ {
+ public static bool Created = false;
+
+ public when_there_are_many_contexts()
+ {
+ Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ public static class OtherTests
+ {
+ public static bool Created = false;
+ }
+
+ class when_there_are_many_contexts_1
+ {
+ when_there_are_many_contexts_1()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_2
+ {
+ when_there_are_many_contexts_2()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_3
+ {
+ when_there_are_many_contexts_3()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_4
+ {
+ when_there_are_many_contexts_4()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_5
+ {
+ when_there_are_many_contexts_5()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_6
+ {
+ when_there_are_many_contexts_6()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_7
+ {
+ when_there_are_many_contexts_7()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_8
+ {
+ when_there_are_many_contexts_8()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_9
+ {
+ when_there_are_many_contexts_9()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_10
+ {
+ when_there_are_many_contexts_10()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_11
+ {
+ when_there_are_many_contexts_11()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_12
+ {
+ when_there_are_many_contexts_12()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_13
+ {
+ when_there_are_many_contexts_13()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_14
+ {
+ when_there_are_many_contexts_14()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_15
+ {
+ when_there_are_many_contexts_15()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_16
+ {
+ when_there_are_many_contexts_16()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_17
+ {
+ when_there_are_many_contexts_17()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_18
+ {
+ when_there_are_many_contexts_18()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_19
+ {
+ when_there_are_many_contexts_19()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_20
+ {
+ when_there_are_many_contexts_20()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_21
+ {
+ when_there_are_many_contexts_21()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_22
+ {
+ when_there_are_many_contexts_22()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_23
+ {
+ when_there_are_many_contexts_23()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_24
+ {
+ when_there_are_many_contexts_24()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_25
+ {
+ when_there_are_many_contexts_25()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_26
+ {
+ when_there_are_many_contexts_26()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_27
+ {
+ when_there_are_many_contexts_27()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_28
+ {
+ when_there_are_many_contexts_28()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_29
+ {
+ when_there_are_many_contexts_29()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_30
+ {
+ when_there_are_many_contexts_30()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_31
+ {
+ when_there_are_many_contexts_31()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_32
+ {
+ when_there_are_many_contexts_32()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_33
+ {
+ when_there_are_many_contexts_33()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_34
+ {
+ when_there_are_many_contexts_34()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_35
+ {
+ when_there_are_many_contexts_35()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_36
+ {
+ when_there_are_many_contexts_36()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_37
+ {
+ when_there_are_many_contexts_37()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_38
+ {
+ when_there_are_many_contexts_38()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_39
+ {
+ when_there_are_many_contexts_39()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_40
+ {
+ when_there_are_many_contexts_40()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_41
+ {
+ when_there_are_many_contexts_41()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_42
+ {
+ when_there_are_many_contexts_42()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_43
+ {
+ when_there_are_many_contexts_43()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_44
+ {
+ when_there_are_many_contexts_44()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_45
+ {
+ when_there_are_many_contexts_45()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_46
+ {
+ when_there_are_many_contexts_46()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_47
+ {
+ when_there_are_many_contexts_47()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_48
+ {
+ when_there_are_many_contexts_48()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_49
+ {
+ when_there_are_many_contexts_49()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_50
+ {
+ when_there_are_many_contexts_50()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_51
+ {
+ when_there_are_many_contexts_51()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_52
+ {
+ when_there_are_many_contexts_52()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_53
+ {
+ when_there_are_many_contexts_53()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_54
+ {
+ when_there_are_many_contexts_54()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_55
+ {
+ when_there_are_many_contexts_55()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_56
+ {
+ when_there_are_many_contexts_56()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_57
+ {
+ when_there_are_many_contexts_57()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_58
+ {
+ when_there_are_many_contexts_58()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_59
+ {
+ when_there_are_many_contexts_59()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_60
+ {
+ when_there_are_many_contexts_60()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_61
+ {
+ when_there_are_many_contexts_61()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_62
+ {
+ when_there_are_many_contexts_62()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_63
+ {
+ when_there_are_many_contexts_63()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_64
+ {
+ when_there_are_many_contexts_64()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_65
+ {
+ when_there_are_many_contexts_65()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_66
+ {
+ when_there_are_many_contexts_66()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_67
+ {
+ when_there_are_many_contexts_67()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_68
+ {
+ when_there_are_many_contexts_68()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_69
+ {
+ when_there_are_many_contexts_69()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_70
+ {
+ when_there_are_many_contexts_70()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_71
+ {
+ when_there_are_many_contexts_71()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_72
+ {
+ when_there_are_many_contexts_72()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_73
+ {
+ when_there_are_many_contexts_73()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_74
+ {
+ when_there_are_many_contexts_74()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_75
+ {
+ when_there_are_many_contexts_75()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_76
+ {
+ when_there_are_many_contexts_76()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_77
+ {
+ when_there_are_many_contexts_77()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_78
+ {
+ when_there_are_many_contexts_78()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_79
+ {
+ when_there_are_many_contexts_79()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_80
+ {
+ when_there_are_many_contexts_80()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_81
+ {
+ when_there_are_many_contexts_81()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_82
+ {
+ when_there_are_many_contexts_82()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_83
+ {
+ when_there_are_many_contexts_83()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_84
+ {
+ when_there_are_many_contexts_84()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_85
+ {
+ when_there_are_many_contexts_85()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_86
+ {
+ when_there_are_many_contexts_86()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_87
+ {
+ when_there_are_many_contexts_87()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_88
+ {
+ when_there_are_many_contexts_88()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_89
+ {
+ when_there_are_many_contexts_89()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_90
+ {
+ when_there_are_many_contexts_90()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_91
+ {
+ when_there_are_many_contexts_91()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_92
+ {
+ when_there_are_many_contexts_92()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_93
+ {
+ when_there_are_many_contexts_93()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_94
+ {
+ when_there_are_many_contexts_94()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_95
+ {
+ when_there_are_many_contexts_95()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_96
+ {
+ when_there_are_many_contexts_96()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_97
+ {
+ when_there_are_many_contexts_97()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_98
+ {
+ when_there_are_many_contexts_98()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_99
+ {
+ when_there_are_many_contexts_99()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+
+ class when_there_are_many_contexts_100
+ {
+ when_there_are_many_contexts_100()
+ {
+ OtherTests.Created = true;
+ }
+
+ It spec = () => { };
+ }
+}
diff --git a/src/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj b/tests/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj
similarity index 79%
rename from src/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj
rename to tests/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj
index a2e918693..42475085b 100644
--- a/src/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj
+++ b/tests/Machine.Specifications.Fixtures/Machine.Specifications.Fixtures.csproj
@@ -1,9 +1,5 @@
-
- false
-
-
diff --git a/tests/Machine.Specifications.Fixtures/RandomFixture.cs b/tests/Machine.Specifications.Fixtures/RandomFixture.cs
new file mode 100644
index 000000000..1545c2aac
--- /dev/null
+++ b/tests/Machine.Specifications.Fixtures/RandomFixture.cs
@@ -0,0 +1,1158 @@
+using System;
+using System.Reflection;
+using System.Threading.Tasks;
+using Machine.Specifications;
+
+namespace Example.Random
+{
+ public class TestAssemblyContext : IAssemblyContext
+ {
+ public static bool OnAssemblyStartRun;
+
+ public static bool OnAssemblyCompleteRun;
+
+ public void OnAssemblyStart()
+ {
+ OnAssemblyStartRun = true;
+ }
+
+ public void OnAssemblyComplete()
+ {
+ OnAssemblyCompleteRun = true;
+ }
+ }
+
+ public static class StaticContainer
+ {
+ static readonly bool Foo;
+
+ static StaticContainer()
+ {
+ Foo = true;
+ }
+
+ public class when_a_context_is_nested_inside_a_static_class
+ {
+ It should_be_run = () =>
+ Foo.ShouldBeTrue();
+ }
+ }
+
+ public class NonStaticContainer
+ {
+ static readonly bool Bar;
+
+ static NonStaticContainer()
+ {
+ Bar = true;
+ }
+
+ public static class StaticContainer
+ {
+ static readonly bool Foo;
+
+ static StaticContainer()
+ {
+ Foo = true;
+ }
+
+ public class when_a_context_is_nested_inside_a_static_class_that_is_nested_inside_a_class
+ {
+ It should_be_run = () =>
+ {
+ Foo.ShouldBeTrue();
+ Bar.ShouldBeTrue();
+ };
+ }
+ }
+ }
+
+ public static class tag
+ {
+ public const string example = "example";
+
+ public const string some_other_tag = "some other tag";
+
+ public const string one_more_tag = "one more tag";
+ }
+
+ [SetupForEachSpecification, Tags(tag.example)]
+ public class context_with_multiple_specifications_and_setup_for_each
+ {
+ public static int establish_run_count;
+
+ public static int because_clause_run_count;
+
+ Establish context = () =>
+ establish_run_count++;
+
+ Because of = () =>
+ because_clause_run_count++;
+
+ It spec1 = () => { };
+
+ It spec2 = () => { };
+ }
+
+ [Tags(tag.example, "foobar")]
+ public class context_with_multiple_specifications
+ {
+ public static int establish_run_count;
+
+ public static int because_clause_run_count;
+
+ Establish context = () =>
+ establish_run_count++;
+
+ Because of = () =>
+ because_clause_run_count++;
+
+ It spec1 = () => { };
+
+ It spec2 = () => { };
+ }
+
+ [Tags(tag.example, tag.example)]
+ [Tags(tag.example)]
+ public class context_with_duplicate_tags
+ {
+ It bla_bla = () => { };
+ }
+
+ [Tags(tag.example, tag.some_other_tag, tag.one_more_tag)]
+ public class context_with_tags
+ {
+ It bla_bla = () => { };
+ }
+
+ public class context_with_unimplemented_specs
+ {
+ It should_be_unimplemented;
+ }
+
+ [Ignore("example reason")]
+ public class context_with_ignore : context_with_no_specs
+ {
+ public static bool ignored_spec_ran;
+
+ It should_be_ignored = () =>
+ ignored_spec_ran = true;
+ }
+
+ public class context_with_ignore_on_one_spec : context_with_no_specs
+ {
+ public static bool ignored_spec_ran;
+
+ [Ignore("example reason")]
+ It should_be_ignored = () =>
+ ignored_spec_ran = true;
+ }
+
+ [Ignore("example reason")]
+ public class context_with_ignore_and_reason : context_with_no_specs
+ {
+ public static bool ignored_spec_ran;
+
+ It should_be_ignored = () =>
+ ignored_spec_ran = true;
+ }
+
+ public class context_with_ignore_and_reason_on_one_spec : context_with_no_specs
+ {
+ public static bool ignored_spec_ran;
+
+ [Ignore("example reason")]
+ It should_be_ignored = () =>
+ ignored_spec_ran = true;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_no_specs
+ {
+ public static bool context_established;
+
+ public static bool cleanup_occurred;
+
+ Establish context = () =>
+ context_established = true;
+
+ Cleanup after_each = () =>
+ cleanup_occurred = true;
+ }
+
+ [Subject(typeof(int), "Some description")]
+ [Tags(tag.example)]
+ public class context_with_subject
+ {
+ }
+
+ public class context_with_parent_with_subject : context_with_subject
+ {
+ }
+
+ [Subject(typeof(int), "Parent description")]
+ public class parent_context
+ {
+ It should_be_able_to_assert_something = () =>
+ true.ShouldBeTrue();
+
+ public class nested_context
+ {
+ It should_be_able_to_assert_something_else = () =>
+ false.ShouldBeFalse();
+ }
+
+ public class nested_context_inheriting_another_concern : context_with_subject
+ {
+ It should_be_able_to_assert_something_else = () =>
+ false.ShouldBeFalse();
+ }
+
+ [Subject(typeof(int), "Nested description")]
+ public class nested_context_inheriting_and_owning_a_concern : context_with_subject
+ {
+ It should_be_able_to_assert_something_else = () =>
+ false.ShouldBeFalse();
+ }
+ }
+
+ public class parent_context_without_concern
+ {
+ It should_be_able_to_assert_something = () =>
+ true.ShouldBeTrue();
+
+ public class nested_context
+ {
+ It should_be_able_to_assert_something_else = () =>
+ false.ShouldBeFalse();
+ }
+ }
+
+ public class parent_context_that_has_its_own_because_block
+ {
+ Because of = () => { };
+
+ public class nested_context_that_has_a_because_block_which
+ {
+ Because of = () => { };
+ }
+ }
+
+ [Tags(tag.example)]
+ public class context_with_failing_specs
+ {
+ It should = () =>
+ throw new InvalidOperationException("something went wrong");
+ }
+
+ [Tags(tag.example)]
+ public class context_with_failing_establish
+ {
+ Establish context = () =>
+ throw new InvalidOperationException("something went wrong");
+
+ It should = () => { };
+ }
+
+ [Tags(tag.example)]
+ public class context_with_failing_because
+ {
+ Because of = () =>
+ throw new InvalidOperationException("something went wrong");
+
+ It should = () => { };
+ }
+
+ [Tags(tag.example)]
+ public class context_with_failing_cleanup
+ {
+ public static readonly Exception ExceptionThrownByCleanup = new InvalidOperationException("something went wrong");
+
+ It should = () => { };
+
+ Cleanup after = () =>
+ {
+ throw ExceptionThrownByCleanup;
+ };
+ }
+
+ [Tags(tag.example)]
+ public class context_with_console_output
+ {
+ Establish context = () =>
+ Console.Out.WriteLine("Console.Out message in establish");
+
+ Because of = () =>
+ Console.Out.WriteLine("Console.Out message in because");
+
+ Cleanup after = () =>
+ Console.Out.WriteLine("Console.Out message in cleanup");
+
+ It should_log_messages = () =>
+ Console.Out.WriteLine("Console.Out message in spec");
+
+ It should_log_messages_also_for_the_nth_spec = () =>
+ Console.Out.WriteLine("Console.Out message in nth spec");
+ }
+
+ [Tags(tag.example)]
+ public class context_with_console_error_output
+ {
+ Establish context = () =>
+ Console.Error.WriteLine("Console.Error message in establish");
+
+ Because of = () =>
+ Console.Error.WriteLine("Console.Error message in because");
+
+ Cleanup after = () =>
+ Console.Error.WriteLine("Console.Error message in cleanup");
+
+ It should_log_messages = () =>
+ Console.Error.WriteLine("Console.Error message in spec");
+
+ It should_log_messages_also_for_the_nth_spec = () =>
+ Console.Error.WriteLine("Console.Error message in nth spec");
+ }
+
+ [Tags(tag.example)]
+ public class context_with_debug_output
+ {
+ Establish context = () =>
+ Console.WriteLine("Debug.WriteLine message in establish");
+
+ Because of = () =>
+ Console.WriteLine("Debug.WriteLine message in because");
+
+ Cleanup after = () =>
+ Console.WriteLine("Debug.WriteLine message in cleanup");
+
+ It should_log_messages = () =>
+ Console.WriteLine("Debug.WriteLine message in spec");
+
+ It should_log_messages_also_for_the_nth_spec = () =>
+ Console.WriteLine("Debug.WriteLine message in nth spec");
+ }
+
+ [SetupForEachSpecification, Tags(tag.example)]
+ public class context_with_console_output_and_setup_for_each
+ {
+ Establish context = () =>
+ Console.Out.WriteLine("Console.Out message in establish");
+
+ Because of = () =>
+ Console.Out.WriteLine("Console.Out message in because");
+
+ Cleanup after = () =>
+ Console.Out.WriteLine("Console.Out message in cleanup");
+
+ It should_log_messages = () =>
+ Console.Out.WriteLine("Console.Out message in spec");
+
+ It should_log_messages_also_for_the_nth_spec = () =>
+ Console.Out.WriteLine("Console.Out message in nth spec");
+ }
+
+ [Tags(tag.example)]
+ public class context_with_inner_exception
+ {
+ It should_throw = () =>
+ {
+ try
+ {
+ throw new Exception("INNER123");
+ }
+ catch (Exception err)
+ {
+ throw new TargetInvocationException(err);
+ }
+ };
+ }
+
+ public class Container
+ {
+ [Tags(tag.example)]
+ public class nested_context
+ {
+ It should_be_run = () => { };
+ }
+ }
+
+ [Tags(tag.example)]
+ public class context_with_public_It_field
+ {
+ public It should;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_protected_It_field
+ {
+ protected It should;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_internal_It_field
+ {
+ internal It should;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_public_Behaves_like_field
+ {
+ public Behaves_like behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_nonprivate_framework_fields
+ {
+ public Establish establish;
+
+ public Because because;
+
+ public Cleanup cleanup;
+
+ internal Behaves_like behavior;
+
+ protected It specification;
+
+ It private_specification;
+ }
+
+ [Tags(tag.example)]
+ public class generic_container
+ {
+ public class nested_context
+ {
+ }
+
+ public class nested_generic_context
+ {
+ public class nested_nested_non_generic
+ {
+ }
+
+ public class nested_nested_generic
+ {
+ }
+ }
+ }
+
+ [Tags(tag.example, "behavior usage")]
+ public class context_with_behaviors
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () => local_spec_ran = true;
+
+ Behaves_like behavior;
+ }
+
+ [Tags(tag.example, "behavior usage")]
+ public class second_context_with_behaviors
+ {
+ Behaves_like behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_where_the_behavior_field_is_ignored
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ [Ignore("example reason")]
+ Behaves_like behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_where_the_behavior_is_ignored
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_where_the_behavior_specs_are_ignored
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_nested_behaviors
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_with_nested_behavior;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_without_behaviors_attribute
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_without_behavior_attribute;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_with_establish
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_with_establish;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_behaviors_with_because
+ {
+ public static bool local_spec_ran;
+
+ It should_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_with_because;
+ }
+
+ [Tags(tag.example)]
+ public class context_missing_protected_fields_that_are_in_behaviors
+ {
+ public static bool local_spec_ran;
+
+ It should_not_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_with_protected_fields;
+ }
+
+ [Tags(tag.example)]
+ public class context_with_protected_fields_having_different_types_than_in_behaviors
+ {
+ public static bool local_spec_ran;
+
+ protected static bool field_that_should_be_copied_over_from_context;
+
+ It should_not_run = () =>
+ local_spec_ran = true;
+
+ Behaves_like behavior_with_protected_fields;
+ }
+
+ [Behaviors]
+ public class Behaviors
+ {
+ public static bool behavior_spec_ran;
+
+ It should_run_if_behavior_is_not_ignored = () =>
+ behavior_spec_ran = true;
+ }
+
+ [Ignore("example reason")]
+ [Behaviors]
+ public class IgnoredBehaviors
+ {
+ public static bool behavior_spec_ran;
+
+ It should_not_run = () =>
+ behavior_spec_ran = true;
+ }
+
+ [Behaviors]
+ public class BehaviorsWithIgnoredSpec
+ {
+ public static bool behavior_spec_ran;
+
+ [Ignore("example reason")]
+ It should_not_run = () =>
+ behavior_spec_ran = true;
+ }
+
+ [Behaviors]
+ public class BehaviorsWithNestedBehavior
+ {
+ Behaves_like