Hmmm... Nothing looks odd there.

What about _mocks?  Is that a per-test variable or a per-test-case variable?

---
Patrick Steele
http://weblogs.asp.net/psteele



On Mon, Nov 29, 2010 at 8:14 AM, Anthony <[email protected]> wrote:
> UnitTestHelpers.GetClockWithAlarms()...
>
>        public static Clock GetClockWithAlarms()
>        {
>            Clock clock = new Clock();
>            GetAlarms().ForEach(a => clock.AddAlarm(a));
>            return clock;
>        }
>
>        public static List<Alarm> GetAlarms()
>        {
>            return new List<Alarm>
>            {
>                new Alarm {Id=1, AlarmName="TestAlarm1", AlarmTime=new
> DateTime(1753,1,1,12,1,0), IsSet=true, Message="Wake up"},
>                new Alarm {Id=2, AlarmName="TestAlarm2", AlarmTime=new
> DateTime(1753,1,1,12,2,0), IsSet=true, Message="Wake up"},
>                new Alarm {Id=2, AlarmName="TestAlarm3", AlarmTime=new
> DateTime(1753,1,1,12,3,0), IsSet=true, Message="Wake up"}
>            };
>        }
>
> On Nov 29, 12:38 pm, Patrick Steele <[email protected]> wrote:
>> What does the "Clock" object returned by
>> "UnitTestHelpers.GetClockWithAlarms()" look like?  Is the Alarms array
>> populated?  I see you're referencing "Alarms[0]" as a parameter to the
>> mapper.Map call.
>>
>> ---
>> Patrick Steelehttp://weblogs.asp.net/psteele
>>
>>
>>
>> On Mon, Nov 29, 2010 at 4:04 AM, Anthony <[email protected]> wrote:
>> > Hi,
>>
>> > Could anyone help me with what is probably a basic question.  I
>> > receive an InvalidOperationException from the code below at the end of
>> > the _mocks.Record() block when I run all my tests together in NUnit
>> > GUI. When I run the tests individually, they all run and pass with no
>> > exception!
>>
>> > I am using Rhino Mocks 3.6 and NUnit 2.5.8 as part of an ASP.NET 4.0
>> > MVC 2 project.
>>
>> > Here is one of my tests, am I doing something wrong with the Record/
>> > Playback syntax?
>>
>> >        [Test]
>> >        public void Can_render_edit_view()
>> >        {
>> >            IClockRepository repo =
>> > _mocks.DynamicMock<IClockRepository>();
>> >            IMapper<Alarm, AlarmViewModel> mapper =
>> > _mocks.DynamicMock<IMapper<Alarm, AlarmViewModel>>();
>> >            var controller = new AlarmController(repo, mapper);
>> >            AlarmViewModel vm = new AlarmViewModel()
>> >            {
>> >                Id = 1,
>> >                AlarmName = "Test",
>> >                AlarmTime = "12:00",
>> >                IsSet = true,
>> >                Message = "Wake up"
>> >            };
>>
>> >            Clock clock = UnitTestHelpers.GetClockWithAlarms();
>> >            using (_mocks.Record())
>> >            {
>> >                Expect.Call(repo.GetClock()).Return(clock);
>> >                Expect.Call(mapper.Map(clock.Alarms[0])).Return(vm);
>> >            }
>> >            ActionResult result;
>> >            using (_mocks.Playback())
>> >            {
>> >                result = controller.Edit(1);
>> >            }
>>
>> >            result.ShouldBeDefaultView();
>> >        }
>>
>> > Any help would be really appreciated!
>>
>> > Anthony
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Rhino.Mocks" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to 
>> > [email protected].
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/rhinomocks?hl=en.- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Rhino.Mocks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rhinomocks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to