I have the following Arrange code
var oRegMgr = Mock.Create<
var oCmdRegion = Mock.Create<
var oCmdView = Mock.Create<
Mock.Arrange(() => oRegMgr.Regions[RegionNames.CommandingRegion]).Returns(oCmdRegion);
Mock.Arrange(() => oCmdRegion.ActiveViews.FirstOrDefault()).Returns(oCmdView);
This calls a function that does this
IRegion commandingRegion = oRegionManager.Regions[RegionNames.CommandingRegion];
CommandingView oCmdView = (CommandingView)commandingRegion.ActiveViews.FirstOrDefault();
(the region manager is returned via a previous call that supplies the mocked region manager, bu that is not germane here, so I have concentrated on the problem area. The access to the region manager sequence is used in several other unit tests, and works fine. When I step thru this in debug, the ProxyRegionManager is in fact the one being used).
I get the mocked region back from oRegionManager just fine. However, when the call to get FirstOrDefault happens, it returns null, NOT the mocked CommandingView.
Am I missing something in the Arrange for invoking FirstOrDefault?