Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Having some difficulty mocking a content type onto a mocked IPublishedContent. Seems there's no interface to PublishedContentType, and the constructor is protected/not accessible.
Mock<IPublishedContent> child = mock.Create<IPublishedContent>();
child.Setup(x => x.Id).Returns(1099);
child.Setup(x => x.Level).Returns(2);
child.Setup(x =>x.ContentType).Returns(A MOCKED CONTENT TYPE);
Ignoring the last line, that works fine to mock out the content.
Is it possible to mock the type as well? Should I just live with 99% test coverage because I can't hit the statement that needs to check the content type ID?
I've taken an alternate path and actually scaffolded out a content tree, populated with real content, but that then has it's own issues where the IPublishedContent versions aren't available due to the cache resolver not being initialized (or something like that).
Any suggestions would be awesome.
P.S. testing is fun.
I think directly mocking is not possible because the ContentType is a concrete class.
I use Unit testing adapter from Lars-Erik and that has method to "mock" it
Nice. Thought I'd read every blog post ever written about testing Umbraco.
I'm in a strange purgatory where I'm wanting to do integration and unit testing, probably more of the former than the latter. So I need a functioning database (which I have), but also need a full Umbraco context, which I kind of have.
Will keep plugging away...
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted