Note that there are some explanatory texts on larger screens.

plurals
  1. PORhino Mocks Error: Previous method 'IEnumerator.MoveNext();' requires a return value or an exception to throw
    primarykey
    data
    text
    <p>I have the following test code:</p> <pre><code>parentViewModel = MockRepository.GenerateMock&lt;IParentViewModel&gt;(); parentViewModel.Expect(x =&gt; x.GetPropertyValue&lt;IEnumerable&lt;Milestone&gt;&gt;("JobMilestones")).Return(new Milestone[0]); viewModel = new JobPenaltiesViewModel(j, new Penalty[0], _opContext, parentViewModel); Assert.That(viewModel.Milestones.Count(), Is.EqualTo(0)); parentViewModel.VerifyAllExpectations(); List&lt;string&gt; propsChanged = new List&lt;string&gt;(); viewModel.PropertyChanged += (s, e) =&gt; propsChanged.Add(e.PropertyName); parentViewModel.Raise(x =&gt; x.PropertyChanged += null, parentViewModel, new PropertyChangedEventArgs("JobMilestones")); AssertPropertiesChangedAsExepected(propsChanged, 1, "Milestones"); Milestone m1 = GenerateMilestone(j); List&lt;Milestone&gt; milestones1 = new List&lt;Milestone&gt; { m1 }; parentViewModel.Expect(x =&gt; x.GetPropertyValue&lt;IEnumerable&lt;Milestone&gt;&gt;("JobMilestones")).Return(milestones1).Repeat.Any(); IEnumerable&lt;Milestone&gt; milestones = viewModel.Milestones; Assert.That(milestones.Count(), Is.EqualTo(1)); parentViewModel.VerifyAllExpectations(); </code></pre> <p>All the tests and assertions succeed up until the:</p> <pre><code>Assert.That(milestones.Count(), Is.EqualTo(1)); </code></pre> <p>That's where I get the exception:</p> <pre><code>Previous method 'IEnumerator.MoveNext();' requires a return value or an exception to throw. </code></pre> <p>I've tried everything I can think of, and my testing seems to indicate that the parentViewModel Mock is returning null, or an empty enumeration (i.e. when I use the debugger to inspect the returned value the 'Results View' says the enumeration returned no results).</p> <p>What am I missing here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload