From the course: Blazor: Getting Started

Unlock the full course today

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

Unit testing components with parameters and services

Unit testing components with parameters and services - Blazor Tutorial

From the course: Blazor: Getting Started

Start my 1-month free trial

Unit testing components with parameters and services

- [Instructor] Now, let's use a mock data service in a test. We'll open up the test project in the counter razor tests. We'll start down here with the fixture test first. The fixture and snapshot tests are only available for X unit at the time of this recording. The syntax allows for a little more flexibility, and it's easier to put a component within a component, but there's nothing that we're testing that we couldn't test with C-Sharp alone. The import.razor here works the same as it does in the client project. Since we're going to be testing our components, let's add beam.client here. Since we're also using our Idata service, we'll add that namespace as well and save. Let's go back to the test fixture. We'll ignore the snapshot test for a minute. We'll change the description to match what we're testing. We'll test, add a new frequency appears in the list and name the test, test frequency list add. I'll copy that…

Contents