I am new to Blazor WebAssembly and unit testing.
I want to do a unit test
- Check whether a API returns with status code 200?
- Check whether the API return correct output
How can I do both?
I tried like this
public class CreateParticipantApiTest : TestContext
{
[Fact]
public void ListAllAsyncShouldReturn200Status ()
{
var cut = RenderComponent<ParticipantsGetAll>(); // I face error at this line
//removed rest
}
}
public class ParticipantsGetAll : IEndpoint<IResult, GetAllParticipantsRequest>
{
// removed
}
Error : CS0311 The type 'ParticipantEndpoints.ParticipantsGetAll' cannot be used as type parameter 'TComponent' in the generic type or method 'TestContext.RenderComponent(params ComponentParameter[])'. There is no implicit reference conversion from 'ParticipantEndpoints.ParticipantsGetAll' to 'Microsoft.AspNetCore.Components.IComponent'. test Test\Participant\CreateParticipantApiTest.cs 27 Active