From the course: Advanced ASP.NET Core: Unit Testing

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

xUnit Theory with ClassData

xUnit Theory with ClassData - ASP.NET Core Tutorial

From the course: Advanced ASP.NET Core: Unit Testing

Start my 1-month free trial

xUnit Theory with ClassData

- [Instructor] You learned how to use the member data attribute to pass parameters to a unit testing method, but member data required aesthetic field, a property, or a method that returns an IEnumerable of an object array, but if you don't want to create aesthetic field, property, or a method to pass data, then you can inherit from the IEnumerable object array in your class, and instead of passing member data, you can then pass the class data using the class data attribute to your unit testing method. So let us go to Visual Studio and see this in action. Before we write any code, let us go to the MathHelper.cs file, and in here we see that the MathFormulas class inherits from the IEnumerable object array, and if you scroll down, we have the implementation of IEnumerable to get the Enumerator, so we can pass a list of data to our unit testing method, and it just returns a list of new object arrays. So let us go to our…

Contents