unit-testing-csharp icon indicating copy to clipboard operation
unit-testing-csharp copied to clipboard

Is it possible to "Freeze" parameter specifying value?

Open raffii90 opened this issue 5 years ago • 2 comments

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"));
    }

raffii90 avatar Sep 09 '20 12:09 raffii90

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:

If you end up creating an issue in AutoFixture, please link this one :)

Kralizek avatar Sep 09 '20 12:09 Kralizek

I created this PR to solve the issue https://github.com/AutoFixture/AutoFixture/pull/1199

Kralizek avatar Sep 19 '20 12:09 Kralizek