Question

I don't really grasp the difference between Customizations and Residue Collectors.

According to Documentation, if I register a customization that can build, ExampleClass it will handle requests for that type that were not handled by other builders. If I register a Residue Collector for type ExampleClass it will handle requests, that were not handled by any (other) builders

Where's the difference?

Was it helpful?

Solution

tl;dr
That's a very valid question. The difference between the two is priority, that is the order in which they're given the chance to handle requests. Customizations are first, while Residue Collectors are last.

AutoFixture, at its core, consists of a Chain of Responsibility where each node in the pipeline is called a specimen builder. These builders are organized in three categories, which determine their position in the chain:

  1. Customizations
  2. Engine
  3. Residue collectors

Specimen builders higher up in the chain get to handle incoming requests first, effectively overriding those that are further down.

Customizations are typically ad-hoc specimen builders created by the user to handle certain kind of requests in a particular way. Hence, they're are given the highest priority.

Engine are the built-in specimen builders that come with AutoFixture. They handle all primitive types such as strings, numbers and dates.

Residue collectors are the specimen builders with the lowest priority and will catch requests that can't be handled by any other builder. They're typically used as fall-back strategy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top