Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:55:45+00:00 2026-05-30T09:55:45+00:00

var contextChannel = this.MockRepository.Stub<IContextChannel>(); var context = this.MockRepository.Stub<IOperationContext>(); context.Stub(x => x.Channel).Return(contextChannel); context.Replay(); What is

  • 0
var contextChannel = this.MockRepository.Stub<IContextChannel>();
var context = this.MockRepository.Stub<IOperationContext>();
context.Stub(x => x.Channel).Return(contextChannel);
context.Replay();

What is Replay for?

I understand that in the case of recording and then playing back an action, the Replay() call is necessary. But it is unclear to me why I am forced to write one more line of code in the case where I do not record anything. All I need is a property which returns my object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:55:46+00:00Added an answer on May 30, 2026 at 9:55 am

    Update:

    You are not using the AAA syntax properly. You don’t need an instance to the MockRepository anymore (this had been used for Rhino before 3.5). Just call the static methods on MockRepository:

    var contextChannel = MockRepository.GenerateStub<IContextChannel>();
    var context = MockRepository.GenerateStub<IOperationContext>();
    context.Stub(x => x.Channel).Return(contextChannel);
    

    Here is some documentation:

    • Rhino Mocks – Arrange, Act, Assert Syntax by Ayende Rahien
    • Rhino Mocks 3.5 official documentation

    Original Answer

    You don’t. There is not need to call Replay in a situations like yours anymore.

    In previous versions, there was a “record-replay” paradigm, where you recorded expectations and replayed them during the test. It had been replaced by the AAA syntax, where you can much easier and more flexible set up mocks.

    Behind the scenes, there is still a record and replay state of the mock. Methods like Stub are putting the mock into record state, configure it, and put them back to record. You don’t need to call Record explicitly in these cases.

    If you want to do some more advanced operations, you can set the mock to replay state yourself, do something with it, eg. in order to reset expectations:

    mock.BackToRecord(BackToRecordOptions.All);
    mock.Replay();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var foo = { p1: function(){ return this.p2; }, p2: function(){ console.log('i am foo.p2');
var fruit = [apple,pear,pear,pear,banana]; How do I remove all pear fruit from this array?
var Model = function(client, collection) { this.client = client; this.collection = collection; }; Model.prototype
var storeSettings = []; obj.find(o_widgetClass).each(function(){ var storeSettingsStr = {}; storeSettingsStr['id'] = $(this).attr('id'); storeSettingsStr['style'] =
var valueAsText = $('#counts span').text(); I use this tiny script to parse a span
var allRapidSpells = $$('input[value^=RSW]'); Can anyone tell me what that does?
var global_ref = null; function a(){ function some_click_handler { global_ref = $(this); } }
var x = 5; function f(y){ return (x+y)-2 }; function g(h){ var x =
var add = []; add[0].url = data.url; add[0].photo = data.thumb; console.log(add); This'll be an
var array = [3,9,23,76,1,54,21,12,0,9,2]; var shuffled = array.sort(function() {return 0.5 - Math.random()}); console.log(shuffled); I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.