Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
3 votes
Accepted

How to mock an ImageField in Sitecore using nSubstitute and xUnit

If you go into ImageField.MediaItem getter, you'll notice that the MediaDatabase.GetItem() method uses 3 parameters including language and version: this.mediaItem = this.MediaDatabase.GetItem(mediaId, ...
user avatar
3 votes

Unit testing a Sitecore component controller throws exception in mocked service

By mocking a proper return type(GetPreviousProductsResponse) value for the injected service(_productService) instead of a model property(PreviousProducts) solved this issue. _productService....
user avatar
2 votes
Accepted

Unit Testing with GlassMapper and GetItemByIdOptions

From what I can see, the reason why it fails for you is because you're using different instances of GetItemByIdOptions class. First you "record" that when service.GetItem will be called with ...
user avatar
1 vote
Accepted

How to mock MediaManager in Sitecore using nSubstitute and xUnit

Change mediaManager.GetMediaUrl(mediaItem).Returns("/a/path/to/an/image.jpg"); to mediaManager.GetMediaUrl(Arg.Is<MediaItem>(mi => mi.ID == mediaItem.ID)).Returns("/a/path/to/...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible