I am using NSubstitute to mock one of my classes/interfaces. One of the functions implemented by my class should return an object of type List.
But when I try to use _mockedObject.MyFunction().Returns(myList), it gives me an error saying I cannot convert between my List and an object of type Func.
I figured I could pass my list as a string using some ToString() function and convert it back? But that doesn't seem particularly clean as I'm expecting a list to come back from my function.
I saw from a video on Unit Testing with Dependency Injection that you can return objects from mocked objects with Moq (https://www.youtube.com/watch?v=DwbYxP-etMY). I am considering switching to that if I can't manage to return an object with NSubstitute.
Aucun commentaire:
Enregistrer un commentaire