2022 Developer Survey is open! Take survey.

Questions tagged [nsubstitute]

Any question related to NSubstitute in Sitecore context can make use of this tag.

Filter by
Sorted by
Tagged with
2 votes
1 answer
62 views

How to mock MediaManager in Sitecore using nSubstitute and xUnit

I am in the process of setting up some unit tests for a Sitecore project (using this guide as a starting point: https://www.codeflood.net/blog/2020/05/17/logicless-view-itemless-model/) I have come ...
user avatar
3 votes
1 answer
94 views

How to mock an ImageField in Sitecore using nSubstitute and xUnit

I am in the process of setting up some unit tests for a Sitecore project (using this guide as a starting point: https://www.codeflood.net/blog/2020/05/17/logicless-view-itemless-model/) I have come ...
user avatar
3 votes
1 answer
108 views

Unit testing a Sitecore component controller throws exception in mocked service

I'm using xUnit, NSubstitute, FluentAssertions and Sitecore FakeDb. Here is the controller that needs a test, public class TransactionsController : Controller { private readonly ...
user avatar
3 votes
1 answer
213 views

Unit Testing with GlassMapper and GetItemByIdOptions

I have some code that retrieves a glass item like this: var root = this.RequestContext.SitecoreService.GetItem<ILookupFolderTemplate>( new GetItemByIdOptions(new Guid("{...
user avatar