unit-testing-csharp
unit-testing-csharp copied to clipboard
Is it possible to "Freeze" parameter specifying value?
It is not an issue, but a question. I wonder is it possible to extend frozen attribute and set the value? To have something like this.
public class TestClass
{
public string TestProperty { get; set; }
}
[Test]
public void Test_method([Frozen("someString")] string parameter, TestClass sut)
{
Assert.That(sut.TestProperty, Is.EqualTo("someString"));
}
The Frozen attribute does not support this use case. In reality what you would like to use is something that can Inject a certain value.
I suggest you asking this question directly at the AutoFixture repo.
If you want, you can even start working on a PR for it. What you'd need is:
- An equivalent of the Frozen attribute, maybe called
Inject - An equivalent to FreezeOnMatchCustomization to inject the given value instead of generating it.
If you end up creating an issue in AutoFixture, please link this one :)
I created this PR to solve the issue https://github.com/AutoFixture/AutoFixture/pull/1199