From the course: C# Unit Testing with xUnit
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Creating a history functionality - C# Tutorial
From the course: C# Unit Testing with xUnit
Creating a history functionality
- [Instructor] This video will focus on the importance of using IDisposable in xUnit tests to ensure the proper setup and teardown of resources. We will implement a history feature for the add function that stores all the results. This will help us understand how to avoid data corruption between tests. Let's get started and create a new test called AddAndStoreInHistory. Now, in our new test for AddAndStoreInHistory our arrange step will be to create a new instance to the calculator. For act we're going to calculate two results. We want to make sure that every time we add numbers in the calculator we're able to go back through the history and see the value that was calculated. We're going to create a variable called result1, and in it we're going to call calc.Add and pass in one, two, three. And our expected result is going to be six. For result2 we'll call calc.Add, and we're going to pass in four, five, six, and the…