Skip to content
Discussion options

You must be logged in to vote

@jzabroski this functionality is already present in AutoFixture. It is enabled via the OmitAutoProperties() method of the
IPostprocessComposer<T>.

[Fact]
public void Foo()
{
    var fixture = new Fixture();

    var person = fixture.Build<Person>()
        .OmitAutoProperties()
        .With(x => x.Photo, fixture.Create<Photo>())
        .Create();

    Assert.NotNull(person.Photo);
    Assert.Null(person.FirstName);
}

You can also selectively omit specific properties using the .Without() method while using Build<T>().

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aivascu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1270 on May 14, 2021 15:42.