I have next code:

var schedule = ScheduleUtil.CreateScheduleDto(user, user);
Expect.Call(() => _scheduleRepository.Save(schedule));

Now, what I need is that after the Save, the id of the schedule should
be changed to a value bigger than 0. If it's created, it is -1.

At the end of the test, _scheduleService.Create(schedule, channelId);
is called. A precondition of code contracts is that the id of the
schedule should be -1 at the beginning of the Save. A postcondition is
that the id of the schedule should be bigger than 0 at the end of the
Save.

Is there a way to do this? To have not an Expect but to make a change
in a certain object?

Hard to explain.

Full code:

[Test]
public void TestCreate()
{
    var channelId = RandomizeUtil.Next(10000);
    var user = UserUtil.CreateRandomUserDto();
    var schedule = ScheduleUtil.CreateScheduleDto(user, user);
    Expect.Call(() => _scheduleRepository.Save(schedule));
    foreach (var userDto in schedule.users)
    {
        Expect.Call(() => _scheduleRepository.AddUser(schedule.id,
userDto.id));
    }
    foreach (var groupDto in schedule.groups)
    {
        Expect.Call(() => _scheduleRepository.AddGroup(schedule.id,
groupDto.id));
    }
 
Expect.Call(_managementConfigurator.RetrieveChannelManager(channelId)).Return(_channelManager);
    Expect.Call(() => _channelManager.HandleNewSchedule(schedule.id));
    _mocks.ReplayAll();
    _scheduleService.Create(schedule, channelId);
    schedule.id = 1; //Otherwise Contract Postcondition
(scheduleDto.id > 0) fails
    _mocks.VerifyAll();
}

-- 
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