I have a Blazor app that I'm writing tests for and it would make everything so much easier if I could just instantiate a view / component and trigger the onclick events etc. straight from my test, rather than from seperate injected classes (I have multiple things injected in the views).
E.g. InjectedClass.cs
public class InjectedClass : IInjectedClass
{
public int MyNumber {get;set;}
public void SetMyNumber(int num)
{
MyNumber = num;
}
}
MyView.razor:
@inject IInjectedClass injectedClass
...
@code{
protected override void OnInitialized()
{
injectedClass.SetMyNumber(5);
}
}
At the moment I have to inject the class into my tests and trigger SetMyNumber manually. I want to be able to instantiate MyView.razor and then run
Assert.That(instanceOfMyView.injectedClass.MyNumber == 5)
but instanceOfMyView.injectedClass is hidden due to protection level.
Here's the error in context :