concept class fixture in category .net

This is an excerpt from Manning's book .NET Core in Action.
Class fixtures share context for one test class, but you may instead need to share context among multiple test classes. The way to handle this in xUnit is with a collection fixture. Creating a collection fixture is simple enough that I always create one when creating a class fixture.
The first step is to add a second, empty class for the collection fixture that uses the class fixture. The following listing shows how to do that with the USRegionFixture class.
Listing 4.17. USRegionFixture with a collection fixture
using BizDayCalc; using Xunit; namespace BizDayCalcTests { public class USRegionFixture { public Calculator Calc { get; private set; } public USRegionFixture() { Calc = new Calculator(); Calc.AddRule(new WeekendRule()); Calc.AddRule(new HolidayRule()); } } [CollectionDefinition("US region collection")] #1 public class USRegionCollection : ICollectionFixture<USRegionFixture> #2 { } }To use the collection fixture in a test class, you need to refer to the collection by name. The test class doesn’t need to implement the IClassFixture interface. Besides those two changes, the test class works just as if you were using a class fixture.
The constructor in a test class lets you share the setup code for each of the test methods. But there are cases where you want a setup operation to be performed once and reused for the entire test class. xUnit’s solution to this is called a class fixture.
The business-day calculator allows you to add many rules, so you want to test the case where many rules are applied. It might be an expensive operation to create a calculator that has all the rules if you have to load those rules from a file or a database. In this case, you can create a class fixture so that the setup and cleanup operations are only performed once for the whole test class.