diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0aec135..64629e0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,7 +15,7 @@ jobs:
runs-on: windows-2022
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v7
with:
fetch-depth: '0' # Use all history for gitversion, cf.: https://github.com/actions/checkout/issues/113
@@ -28,12 +28,12 @@ jobs:
# - https://itnext.io/how-to-support-multiple-net-sdks-in-github-actions-workflows-b988daa884e
# - https://github.com/actions/setup-dotnet
- name: Setup dotnet
- uses: actions/setup-dotnet@v1
+ uses: actions/setup-dotnet@v5
with:
dotnet-version: |
- 3.1.x
- 5.0.x
6.0.x
+ 8.0.x
+ 10.0.x
- run: .\build.ps1 CiBuild
env:
diff --git a/FluentAssertions.Autofac.Tests/FluentAssertions.Autofac.Tests.csproj b/FluentAssertions.Autofac.Tests/FluentAssertions.Autofac.Tests.csproj
index ae7da4c..7f68383 100644
--- a/FluentAssertions.Autofac.Tests/FluentAssertions.Autofac.Tests.csproj
+++ b/FluentAssertions.Autofac.Tests/FluentAssertions.Autofac.Tests.csproj
@@ -6,10 +6,7 @@
-
-
-
- net6.0
+ net47;net6.0;net8.0;net10.0
false
FluentAssertions.Autofac
@@ -17,16 +14,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/FluentAssertions.Autofac/AutofacAssertionExtensions.cs b/FluentAssertions.Autofac/AutofacAssertionExtensions.cs
index 133095b..98f1050 100644
--- a/FluentAssertions.Autofac/AutofacAssertionExtensions.cs
+++ b/FluentAssertions.Autofac/AutofacAssertionExtensions.cs
@@ -1,4 +1,5 @@
using Autofac;
+using FluentAssertions.Execution;
namespace FluentAssertions.Autofac;
@@ -16,7 +17,7 @@ public static class AutofacAssertionExtensions
///
public static ContainerAssertions Should(this IComponentContext container)
{
- return new ContainerAssertions(container);
+ return new ContainerAssertions(container, AssertionChain.GetOrCreate());
}
///
@@ -25,6 +26,6 @@ public static ContainerAssertions Should(this IComponentContext container)
///
public static BuilderAssertions Should(this ContainerBuilder builder)
{
- return new BuilderAssertions(builder);
+ return new BuilderAssertions(builder, AssertionChain.GetOrCreate());
}
}
diff --git a/FluentAssertions.Autofac/BuilderAssertions.cs b/FluentAssertions.Autofac/BuilderAssertions.cs
index ddf2f30..eaf6c0b 100644
--- a/FluentAssertions.Autofac/BuilderAssertions.cs
+++ b/FluentAssertions.Autofac/BuilderAssertions.cs
@@ -34,8 +34,10 @@ public class BuilderAssertions : ReferenceTypeAssertions class.
///
///
+ /// The current
///
- public BuilderAssertions(ContainerBuilder subject) : base(subject)
+ public BuilderAssertions(ContainerBuilder subject, AssertionChain assertionChain)
+ : base(subject, assertionChain)
{
}
@@ -56,7 +58,7 @@ public void RegisterModule(Type moduleType)
{
EnsureVisited();
var module = _modules.FirstOrDefault(m => m.GetType() == moduleType);
- Execute.Assertion
+ CurrentAssertionChain
.ForCondition(module != null)
.FailWith($"Module '{moduleType}' should be registered but it was not.");
}
diff --git a/FluentAssertions.Autofac/ContainerAssertions.cs b/FluentAssertions.Autofac/ContainerAssertions.cs
index 8c74fae..9c35b8b 100644
--- a/FluentAssertions.Autofac/ContainerAssertions.cs
+++ b/FluentAssertions.Autofac/ContainerAssertions.cs
@@ -5,6 +5,7 @@
using System.Reflection;
using Autofac;
using Autofac.Util;
+using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace FluentAssertions.Autofac;
@@ -29,7 +30,9 @@ public class ContainerAssertions : ReferenceTypeAssertions class.
///
/// The subject
- public ContainerAssertions(IComponentContext container) : base(container)
+ /// The current
+ public ContainerAssertions(IComponentContext container, AssertionChain assertionChain)
+ : base(container, assertionChain)
{
}
@@ -39,7 +42,7 @@ public ContainerAssertions(IComponentContext container) : base(container)
///
public ContainerRegistrationAssertions Have()
{
- return new ContainerRegistrationAssertions(Subject);
+ return new ContainerRegistrationAssertions(Subject, CurrentAssertionChain);
}
///
@@ -48,7 +51,7 @@ public ContainerRegistrationAssertions Have()
///
public ResolveAssertions Resolve(Type serviceType)
{
- return new ResolveAssertions(Subject, serviceType);
+ return new ResolveAssertions(Subject, serviceType, CurrentAssertionChain);
}
///
@@ -86,7 +89,7 @@ public void AutoActivate()
public TypeScanningAssertions RegisterAssemblyTypes(params Assembly[] assemblies)
{
var types = assemblies.SelectMany(assembly => assembly.GetLoadableTypes());
- return new TypeScanningAssertions(Subject, types);
+ return new TypeScanningAssertions(Subject, types, CurrentAssertionChain);
}
///
@@ -96,6 +99,6 @@ public TypeScanningAssertions RegisterAssemblyTypes(params Assembly[] assemblies
///
public TypeScanningAssertions RegisterTypes(IEnumerable types)
{
- return new TypeScanningAssertions(Subject, types);
+ return new TypeScanningAssertions(Subject, types, CurrentAssertionChain);
}
}
diff --git a/FluentAssertions.Autofac/ContainerRegistrationAssertions.cs b/FluentAssertions.Autofac/ContainerRegistrationAssertions.cs
index d2e5342..db9fab6 100644
--- a/FluentAssertions.Autofac/ContainerRegistrationAssertions.cs
+++ b/FluentAssertions.Autofac/ContainerRegistrationAssertions.cs
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Autofac;
+using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace FluentAssertions.Autofac;
@@ -27,7 +28,9 @@ public class
/// Initializes a new instance of the class.
///
/// The subject
- public ContainerRegistrationAssertions(IComponentContext subject) : base(subject)
+ /// The current
+ public ContainerRegistrationAssertions(IComponentContext subject, AssertionChain assertionChain)
+ : base(subject, assertionChain)
{
}
@@ -37,7 +40,7 @@ public ContainerRegistrationAssertions(IComponentContext subject) : base(subject
///
public RegisterAssertions Registered()
{
- return new RegisterAssertions(Subject, typeof(TService));
+ return new RegisterAssertions(Subject, typeof(TService), CurrentAssertionChain);
}
///
@@ -46,7 +49,7 @@ public RegisterAssertions Registered()
///
public RegisterAssertions Registered(Type type)
{
- return new RegisterAssertions(Subject, type);
+ return new RegisterAssertions(Subject, type, CurrentAssertionChain);
}
///
@@ -58,7 +61,7 @@ public RegisterAssertions Registered(object instance)
if (instance == null)
throw new ArgumentNullException(nameof(instance));
- return new RegisterAssertions(Subject, instance.GetType());
+ return new RegisterAssertions(Subject, instance.GetType(), CurrentAssertionChain);
}
///
@@ -135,6 +138,6 @@ public void NotRegistered(object serviceKey, Type type)
///
public RegisterGenericSourceAssertions RegisteredGeneric(Type genericComponentTypeDefinition)
{
- return new RegisterGenericSourceAssertions(Subject, genericComponentTypeDefinition);
+ return new RegisterGenericSourceAssertions(Subject, genericComponentTypeDefinition, CurrentAssertionChain);
}
}
diff --git a/FluentAssertions.Autofac/FluentAssertions.Autofac.csproj b/FluentAssertions.Autofac/FluentAssertions.Autofac.csproj
index e0c9dbf..1481f49 100644
--- a/FluentAssertions.Autofac/FluentAssertions.Autofac.csproj
+++ b/FluentAssertions.Autofac/FluentAssertions.Autofac.csproj
@@ -5,17 +5,17 @@
-
- net6.0;net5.0;netcoreapp3.1;net48;net472;netstandard2.0;netstandard2.1
+
+ net47;net6.0;netstandard2.0;netstandard2.1
true
false
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/FluentAssertions.Autofac/RegisterAssertions.cs b/FluentAssertions.Autofac/RegisterAssertions.cs
index 193b364..c503546 100644
--- a/FluentAssertions.Autofac/RegisterAssertions.cs
+++ b/FluentAssertions.Autofac/RegisterAssertions.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Reflection;
using Autofac;
+using FluentAssertions.Execution;
namespace FluentAssertions.Autofac;
@@ -19,7 +20,9 @@ public class RegisterAssertions : RegistrationAssertions
///
/// The container
/// The type that should be registered on the container
- public RegisterAssertions(IComponentContext subject, Type type) : base(subject, type)
+ /// The current
+ public RegisterAssertions(IComponentContext subject, Type type, AssertionChain assertionChain)
+ : base(subject, type, assertionChain)
{
}
@@ -67,7 +70,7 @@ public RegisterAssertions AsImplementedInterfaces()
private void AssertResolveAs(Type serviceType)
{
- new ResolveAssertions(Subject, serviceType).As(Type);
+ new ResolveAssertions(Subject, serviceType, CurrentAssertionChain).As(Type);
}
private static List GetImplementedInterfaces(Type type)
diff --git a/FluentAssertions.Autofac/RegisterGenericSourceAssertions.cs b/FluentAssertions.Autofac/RegisterGenericSourceAssertions.cs
index b042d29..37f5024 100644
--- a/FluentAssertions.Autofac/RegisterGenericSourceAssertions.cs
+++ b/FluentAssertions.Autofac/RegisterGenericSourceAssertions.cs
@@ -5,6 +5,7 @@
using Autofac;
using Autofac.Core;
using Autofac.Core.Resolving.Pipeline;
+using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace FluentAssertions.Autofac;
@@ -33,8 +34,9 @@ public class
///
/// The component context
/// The type that should be registered on the container
- public RegisterGenericSourceAssertions(IComponentContext subject, Type type) :
- base(subject)
+ /// The current
+ public RegisterGenericSourceAssertions(IComponentContext subject, Type type, AssertionChain assertionChain)
+ : base(subject, assertionChain)
{
AssertGenericType(type);
_type = type;
@@ -49,7 +51,7 @@ public RegistrationAssertions As(Type type)
var serviceType = GenericServiceTypeFor(type, out var componentType);
var service = new TypedService(serviceType);
var registration = RegistrationFor(type, service, componentType);
- return new RegistrationAssertions(Subject, registration);
+ return new RegistrationAssertions(Subject, registration, CurrentAssertionChain);
}
///
@@ -62,7 +64,7 @@ public RegistrationAssertions Named(string serviceName, Type type)
var serviceType = GenericServiceTypeFor(type, out var componentType);
var service = new KeyedService(serviceName, serviceType);
var registration = RegistrationFor(type, service, componentType);
- return new RegistrationAssertions(Subject, registration);
+ return new RegistrationAssertions(Subject, registration, CurrentAssertionChain);
}
private IComponentRegistration RegistrationFor(Type type, Service service, Type componentType)
diff --git a/FluentAssertions.Autofac/RegistrationAssertions.cs b/FluentAssertions.Autofac/RegistrationAssertions.cs
index eda3c1a..329a16a 100644
--- a/FluentAssertions.Autofac/RegistrationAssertions.cs
+++ b/FluentAssertions.Autofac/RegistrationAssertions.cs
@@ -7,6 +7,7 @@
using Autofac.Core;
using Autofac.Core.Activators.Reflection;
using Autofac.Core.Lifetime;
+using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace FluentAssertions.Autofac;
@@ -40,7 +41,9 @@ public class RegistrationAssertions : ReferenceTypeAssertions
/// The container
/// The type that should be registered on the container
- public RegistrationAssertions(IComponentContext subject, Type type) : base(subject)
+ /// The current
+ public RegistrationAssertions(IComponentContext subject, Type type, AssertionChain assertionChain)
+ : base(subject, assertionChain)
{
Type = type ?? throw new ArgumentNullException(nameof(type));
_registration = Subject.ComponentRegistry.GetRegistration(Type);
@@ -52,7 +55,9 @@ public RegistrationAssertions(IComponentContext subject, Type type) : base(subje
///
/// The container
///
- public RegistrationAssertions(IComponentContext subject, IComponentRegistration registration) : base(subject)
+ /// The current
+ public RegistrationAssertions(IComponentContext subject, IComponentRegistration registration, AssertionChain assertionChain)
+ : base(subject, assertionChain)
{
_registration = registration ?? throw new ArgumentNullException(nameof(registration));
Type = registration.Activator.LimitType;
diff --git a/FluentAssertions.Autofac/ResolveAssertions.cs b/FluentAssertions.Autofac/ResolveAssertions.cs
index 9e51483..a7d8f1d 100644
--- a/FluentAssertions.Autofac/ResolveAssertions.cs
+++ b/FluentAssertions.Autofac/ResolveAssertions.cs
@@ -33,7 +33,9 @@ public class ResolveAssertions : ReferenceTypeAssertions
/// The container
/// The service type
- public ResolveAssertions(IComponentContext container, Type serviceType) : base(container)
+ /// The current
+ public ResolveAssertions(IComponentContext container, Type serviceType, AssertionChain assertionChain)
+ : base(container, assertionChain)
{
_serviceType = serviceType;
var typeToResolve = typeof(IEnumerable<>).MakeGenericType(serviceType);
@@ -42,7 +44,7 @@ public ResolveAssertions(IComponentContext container, Type serviceType) : base(c
_instances.AddRange(array.OfType