Skip to content
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
23 changes: 23 additions & 0 deletions Atc.Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atc.Test", "src\Atc.Test\At
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atc.Test.Tests", "test\Atc.Test.Tests\Atc.Test.Tests.csproj", "{FE44F21D-22E5-47ED-A551-74AF79E23C89}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{23CF9054-75B8-4E9E-A252-52C5C1455ECA}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2E82F528-471D-4451-ADD9-C0AF97692C8D}"
ProjectSection(SolutionItems) = preProject
src\.editorconfig = src\.editorconfig
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4B46C47D-DE74-4FA4-9A27-4CBCB354AE05}"
ProjectSection(SolutionItems) = preProject
test\.editorconfig = test\.editorconfig
test\Directory.Build.props = test\Directory.Build.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -45,6 +64,10 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7E15F9B0-040B-454B-BD29-E0A0CBC3473B} = {2E82F528-471D-4451-ADD9-C0AF97692C8D}
{FE44F21D-22E5-47ED-A551-74AF79E23C89} = {4B46C47D-DE74-4FA4-9A27-4CBCB354AE05}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5E657CBB-3A3C-4C41-B832-7ACE196175AD}
EndGlobalSection
Expand Down
9 changes: 6 additions & 3 deletions src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ public override IEnumerable<object[]> GetData(MethodInfo testMethod)
var fixture = FixtureFactory.Create();
foreach (var frozenValue in frozenValues)
{
injectMethod?
.MakeGenericMethod(frozenValue.ParameterType)
.Invoke(null, [fixture, values[frozenValue.Index]]);
if (values.Length > frozenValue.Index)
{
injectMethod?
.MakeGenericMethod(frozenValue.ParameterType)
.Invoke(null, [fixture, values[frozenValue.Index]]);
}
}

yield return values
Expand Down
3 changes: 2 additions & 1 deletion test/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ dotnet_diagnostic.CA1812.severity = none # Test classes used as gener
dotnet_diagnostic.SA1202.severity = none # Private helper methods makes sense to keep at top of test classes, as tests are added to bottom.
dotnet_diagnostic.CA2201.severity = none # Instantiating Exceptions as test data should be allowed.
dotnet_diagnostic.CA1711.severity = none # Identifiers should not have incorrect suffix
dotnet_diagnostic.S2344.severity = none # Enumeration type names should not have "Flags" or "Enum" suffixes
dotnet_diagnostic.S2344.severity = none # Enumeration type names should not have "Flags" or "Enum" suffixes
dotnet_diagnostic.CA1515.severity = none # CA1515: Consider making public types internal
31 changes: 31 additions & 0 deletions test/Atc.Test.Tests/ClassAutoNSubstituteDataAttributeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Atc.Test.Tests;

public class ClassAutoNSubstituteDataAttributeTests
{
public class TestData : TheoryData<SampleEnum>
{
public TestData()
{
AddRow(SampleEnum.One);
AddRow(SampleEnum.Two);
AddRow(SampleEnum.Three);
}
}

[Theory]
[ClassAutoNSubstituteData(typeof(TestData))]
public void MemberAutoNSubstituteData_Should_Call_For_MemberData(
SampleEnum value,
[Frozen] ISampleInterface interfaceType,
SampleClass concreteType,
SampleDependantClass dependantType)
{
value.Should().BeOneOf(SampleEnum.One, SampleEnum.Two, SampleEnum.Three);
interfaceType.Should().NotBeNull();
interfaceType.IsSubstitute().Should().BeTrue();
concreteType.Should().NotBeNull();
concreteType.IsSubstitute().Should().BeFalse();
dependantType.Should().NotBeNull();
dependantType.Dependency.Should().Be(interfaceType);
}
}
Loading