ClassData is another attribute that can be used to create data-driven tests by using data coming from a class. The ClassData attribute takes a class that can be instantiated to fetched data that will be used to execute the data theories. The class with the data must implement IEnumerable<object[]> with each data item returned as an object array. The GetEnumerator method must also be implemented.
Let's create a LoanDTOData class to be used to provide data to test the Test_CalculateLoan_ShouldReturnCorrectRate method. LoanDTOData will return IEnumerable objects of LoanDTO:
public class LoanDTOData : IEnumerable<object[]>{ private IEnumerable<object[]> data => new[] { new object[] { new LoanDTO { LoanType = LoanType.CarLoan, ...