I used Fluxor for state management in in one of the razor components in my Blazor app and I'm not really sure how to set it up for testing with Moq. I can't just assing a value to students because it's an init only property. Is there a specific way to set up Fluxor for testing?
code
var teacherService = new Mock<ITeacherService>();
var localStorage = new Mock<ILocalStorageService>();
var studentService = new Mock<IStudentService>();
var toastService = new Mock<IToastService>();
var NavigationManager = new Mock<NavigationManager>();
var Dispatcher = new Mock<IDispatcher>();
var actionSubscriber = new Mock<IActionSubscriber>();
var StudentsState = new Mock<IState<StudentsState>>();
var TeacherState = new Mock<IState<TeacherState>>();
// Help here
StudentsState.Setup(t => t.Value.Students = )
The way I did this was to use the set up to return a whole state record, configured the way that I wanted it.
So if you have a IState where StudentsState is readonly
You can do:
If you need more complext interaction with the state you need to actually set up Fluxor to run on the TestContext something like:
(Note that if you set up the Fluxor like this then you'll need to mock up your data source so that fluxor can load up the data in the Effect)