Unit testing: moqing out IPublishedContent with child nodes

hello out there,

making slow progress with unit testing but had some sucsess today (http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/60476-unit-testing-creating-an-UmbracoContext-throws-an-exception!) but’ve got a new one:

one of the tests we’re trying to write requires a mocked out IPublishedContent with child nodes.

this is what we have:

var repo = new MockRepository(MockBehavior.Default);
var node = repo.Create<IPublishedContent>();
node.Setup(x => x.Id).Returns(1);
node.Setup(x => x.DocumentTypeAlias).Returns("Folder");

but for our test to run we need to populate:

node.Setup(x => x.Children).Returns(WhatGoesHere?);

more specificallty, for this particluar test the 1st child needs to have a ‘DocumentTypeAlias’ of ‘Image’.

the trick is that ‘Children’ is a ‘IEnumerable’ - just can’t see a way to populate the IEnumerable?!

any clues?

cheers,

jake


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/60514-unit-testing-moqing-out-ipublishedcontent-with-child-nodes