Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,110 @@ public async Task WithType_WithName_ShouldFilterForConstructorsWithInParameterOf
}
}

public sealed class DescriptionTests
{
[Fact]
public async Task ParameterlessFilter_ShouldMatchConstructorWithOnlySomeInParameters()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter();

await That(constructors).Contains(MixedConstructor());
}

[Fact]
public async Task OfType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter<int>();

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task OfTypeWithName_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter<int>("value");

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task ByName_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter("value");

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task ExactlyOfType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameterExactly<int>();

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameterExactly<int>("value");

await That(constructors.GetDescription()).Contains("with in modifier");
}

#pragma warning disable CA2263
[Fact]
public async Task OfType_UsingType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter(typeof(int));

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task OfTypeWithName_UsingType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameter(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task ExactlyOfType_UsingType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameterExactly(typeof(int));

await That(constructors.GetDescription()).Contains("with in modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_UsingType_ShouldDescribeWithInModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithInParameterExactly(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with in modifier");
}
#pragma warning restore CA2263
}

private static ConstructorInfo? InParameterConstructor()
=> typeof(ClassWithInParameterConstructor).GetConstructors().Single();

private static ConstructorInfo? PlainConstructor()
=> typeof(ClassWithPlainConstructor).GetConstructors().Single();

private static ConstructorInfo? MixedConstructor()
=> typeof(ClassWithMixedConstructor).GetConstructors().Single();

// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedParameter.Local
private class ClassWithInParameterConstructor
Expand All @@ -80,6 +178,13 @@ public ClassWithPlainConstructor(int value)
{
}
}

private class ClassWithMixedConstructor
{
public ClassWithMixedConstructor(in int value, string other)
{
}
}
// ReSharper restore UnusedParameter.Local
// ReSharper restore UnusedMember.Local
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,110 @@ public async Task WithType_WithName_ShouldFilterForConstructorsWithOptionalParam
}
}

public sealed class DescriptionTests
{
[Fact]
public async Task ParameterlessFilter_ShouldMatchConstructorWithOnlySomeOptionalParameters()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter();

await That(constructors).Contains(MixedConstructor());
}

[Fact]
public async Task OfType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter<int>();

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task OfTypeWithName_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter<int>("value");

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task ByName_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter("value");

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task ExactlyOfType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameterExactly<int>();

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameterExactly<int>("value");

await That(constructors.GetDescription()).Contains("with optional modifier");
}

#pragma warning disable CA2263
[Fact]
public async Task OfType_UsingType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter(typeof(int));

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task OfTypeWithName_UsingType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameter(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task ExactlyOfType_UsingType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameterExactly(typeof(int));

await That(constructors.GetDescription()).Contains("with optional modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_UsingType_ShouldDescribeWithOptionalModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOptionalParameterExactly(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with optional modifier");
}
#pragma warning restore CA2263
}

private static ConstructorInfo? OptionalParameterConstructor()
=> typeof(ClassWithOptionalParameterConstructor).GetConstructors().Single();

private static ConstructorInfo? PlainConstructor()
=> typeof(ClassWithPlainConstructor).GetConstructors().Single();

private static ConstructorInfo? MixedConstructor()
=> typeof(ClassWithMixedConstructor).GetConstructors().Single();

// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedParameter.Local
private class ClassWithOptionalParameterConstructor
Expand All @@ -80,6 +178,13 @@ public ClassWithPlainConstructor(int value)
{
}
}

private class ClassWithMixedConstructor
{
public ClassWithMixedConstructor(string other, int value = 0)
{
}
}
// ReSharper restore UnusedParameter.Local
// ReSharper restore UnusedMember.Local
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,110 @@ public async Task WithType_WithName_ShouldFilterForConstructorsWithOutParameterO
}
}

public sealed class DescriptionTests
{
[Fact]
public async Task ParameterlessFilter_ShouldMatchConstructorWithOnlySomeOutParameters()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter();

await That(constructors).Contains(MixedConstructor());
}

[Fact]
public async Task OfType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter<int>();

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task OfTypeWithName_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter<int>("value");

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task ByName_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter("value");

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task ExactlyOfType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameterExactly<int>();

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameterExactly<int>("value");

await That(constructors.GetDescription()).Contains("with out modifier");
}

#pragma warning disable CA2263
[Fact]
public async Task OfType_UsingType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter(typeof(int));

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task OfTypeWithName_UsingType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameter(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task ExactlyOfType_UsingType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameterExactly(typeof(int));

await That(constructors.GetDescription()).Contains("with out modifier");
}

[Fact]
public async Task ExactlyOfTypeWithName_UsingType_ShouldDescribeWithOutModifier()
{
Filtered.Constructors constructors = In.AssemblyContaining<AssemblyFilters>()
.Constructors().WithOutParameterExactly(typeof(int), "value");

await That(constructors.GetDescription()).Contains("with out modifier");
}
#pragma warning restore CA2263
}

private static ConstructorInfo? OutParameterConstructor()
=> typeof(ClassWithOutParameterConstructor).GetConstructors().Single();

private static ConstructorInfo? PlainConstructor()
=> typeof(ClassWithPlainConstructor).GetConstructors().Single();

private static ConstructorInfo? MixedConstructor()
=> typeof(ClassWithMixedConstructor).GetConstructors().Single();

// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedParameter.Local
private class ClassWithOutParameterConstructor
Expand All @@ -81,6 +179,14 @@ public ClassWithPlainConstructor(int value)
{
}
}

private class ClassWithMixedConstructor
{
public ClassWithMixedConstructor(out int value, string other)
{
value = 0;
}
}
// ReSharper restore UnusedParameter.Local
// ReSharper restore UnusedMember.Local
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ await That(constructors).IsEqualTo([
typeof(TestClass).GetConstructor([typeof(DummyBase),])!,
]).InAnyOrder();
await That(constructors.GetDescription())
.IsEqualTo("constructors with parameter of exact type ").AsPrefix();
.Contains("and name equal to \"parameter\"");
}

[Fact]
Expand Down Expand Up @@ -91,7 +91,7 @@ await That(constructors).IsEqualTo([
typeof(TestClass).GetConstructor([typeof(DummyBase),])!,
]).InAnyOrder();
await That(constructors.GetDescription())
.IsEqualTo("constructors with parameter of exact type ").AsPrefix();
.Contains("and name equal to \"parameter\"");
}
}

Expand Down
Loading
Loading