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 - ASP.NET Core Tutorial
From the course: Advanced ASP.NET Core: Unit Testing
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
ASP.NET Core console project overview1m 46s
-
(Locked)
Set up the console testing project5m 20s
-
(Locked)
xUnit Theory with InlineData6m 15s
-
(Locked)
Challenge: Test add and average methods51s
-
(Locked)
Solution: Test add and average methods4m 25s
-
(Locked)
xUnit Theory with MemberData4m 29s
-
(Locked)
xUnit Theory with ClassData4m 7s
-
-
-
-