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.
Parsing a math equation string - C# Tutorial
From the course: C# Unit Testing with xUnit
Parsing a math equation string
- [Instructor] In this final video, we're going to demonstrate a step-by-step process to parse a mathematical equation from a string. This is useful for when processing a user provided input or creating dynamic equations based on program variables. We'll not only create the test to make sure that this works, but we'll also walk through the process, covering error handling and the operational proceedings. Let's get started by writing a new test. We'll start by creating a theory, and we'll set up inline data to test whether the string of two plus three will equal the integer five. Let's create another inline data test for five minus three, equaling two. The next inline data test will be four plus six minus two equals eight, and the final inline data test will be 10 plus 20 minus five plus eight equals 33. We'll name the method parse equation string, and it will accept an equation as a string and an expected value as an integer.…