title: Rhino mocks exception with CompositionContainer
body: <pre><code>[TestFixture]
  public class UnitListViewModelTests
  {
      private CompositionContainer _container;
      private INHDataService _nhDataService;
      private INHUnitOfWork _nhUoW;
  
      [SetUp]
      [TestCase]
      public void create_container()
      {
          _container = MockRepository.GeneratePartialMock&lt;CompositionContainer&gt;();
          _nhDataService = MockRepository.GenerateMock&lt;INHDataService&gt;();
          _nhUoW = MockRepository.GenerateMock&lt;INHUnitOfWork&gt;();
  
          _container.Expect(x =&gt; x.GetExportedValue&lt;INHDataService&gt;()).IgnoreArguments().Return(_nhDataService);
      }
  }
  </code></pre>
  
  <p>this code throws an exception at <code>_container.Expect...</code>.</p>
  
  <pre><code>SetUp : System.InvalidOperationException : Previous method 'IEnumerator.MoveNext();' requires a return value or an exception to throw.
     at Rhino.Mocks.Impl.RecordMockState.AssertPreviousMethodIsClose()
     at Rhino.Mocks.Impl.RecordMockState.MethodCall(IInvocation invocation, MethodInfo method, Object[] args)
     at Rhino.Mocks.MockRepository.MethodCall(IInvocation invocation, Object proxy, MethodInfo method, Object[] args)
     at Rhino.Mocks.Impl.Invocation.Actions.RegularInvocation.PerformAgainst(IInvocation invocation)
     at Rhino.Mocks.Impl.RhinoInterceptor.Intercept(IInvocation invocation)
     at Castle.DynamicProxy.AbstractInvocation.Proceed()
     at Castle.Proxies.IEnumerator`1Proxy15c4de116cb145039cc424d2b9ced840.IDisposable.Dispose()
     at Microsoft.Internal.Collections.CollectionServices.GetCardinality[T](IEnumerable`1 source)
     at System.ComponentModel.Composition.ExportServices.CheckCardinality(ImportDefinition definition, IEnumerable`1 exports)
     at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1&amp; exports)
     at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
     at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
     at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
     at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName)
     at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]()
     at MIB.Test.ViewModels.UnitListViewModelTests.&lt;create_container&gt;b__0(CompositionContainer x) in E:\Work\MIB\MIB.Test\ViewModels\UnitListViewModelTests.cs:line 29#0
     at Rhino.Mocks.RhinoMocksExtensions.Expect[T,R](T mock, Function`2 action)
     at MIB.Test.ViewModels.UnitListViewModelTests.create_container() in E:\Work\MIB\MIB.Test\ViewModels\UnitListViewModelTests.cs:line 29#1
  </code></pre>
  
  <p>Edit:
  I tried this also but it still throws an exception:</p>
  
  <pre><code>_container.Stub(x =&gt; x.GetExportedValue&lt;INHDataService&gt;()).IgnoreArguments().Return(_nhDataService);
  </code></pre>