Is your feature request related to a problem? Please describe.
I'm writing some unit tests with xUnit. To have them a bit more structured, I bundle method related unit tests in a sub class, within the main test class, like so:
[assembly: Rock(typeof(IBarManager), BuildType.Create)]
namspace ...
public class FooServiceTest
{
public class FooTestBase
{
private readonly IBarManagerCreateExpectations _barManagerCreateExpectations;
private readonly IFooService _fooService; // or sut (system under test)
// Constructor
}
// GetItem is a method of IFooService
public class GetItem : FooTestBase
{
[Fact]
public void GetItem()
{
// test logic
// Make use of _barManagerCreateExpectations here
}
}
// GetDefinition is a method of IFooService
public class GetDefinition : FooTestBase
{
[Fact]
public void GetDefinition()
{
// test logic
// Make use of _barManagerCreateExpectations here
}
}
}
Which does not work, because IBarManagerCreateExpectations is internal. Is there a reason, which I don't understand yet, that the generated classes are internal sealed, like seen below?
|
writer.WriteLines( |
|
$$""" |
|
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] |
|
internal sealed class {{mockType.ExpectationsName}} |
|
: global::Rocks.Expectations |
|
"""); |
Describe the solution you'd like
I'd like to have the option to set the access modifier for a class. For example when using the RockAttribute:
[assembly: Rock(typeof(IBarManager), BuildType.Create, Modifier.Public)]
Describe alternatives you've considered
I can move away from using sub classes, sure.
Additional context
none
Is your feature request related to a problem? Please describe.
I'm writing some unit tests with xUnit. To have them a bit more structured, I bundle method related unit tests in a sub class, within the main test class, like so:
Which does not work, because
IBarManagerCreateExpectationsisinternal. Is there a reason, which I don't understand yet, that the generated classes areinternal sealed, like seen below?Rocks/src/Rocks/Builders/Create/MockBuilder.cs
Lines 16 to 21 in f85a77d
Describe the solution you'd like
I'd like to have the option to set the access modifier for a class. For example when using the
RockAttribute:Describe alternatives you've considered
I can move away from using sub classes, sure.
Additional context
none