Skip to content
This repository has been archived by the owner on Oct 21, 2018. It is now read-only.

Enable the possibility of removing a determined expectation or give access to the rootRecorder #19

Open
marcoslimagon opened this issue Apr 20, 2016 · 1 comment

Comments

@marcoslimagon
Copy link

I think that could be useful to remove an pre-defined expectation.

public void BackToRecord(object obj, BackToRecordOptions options) { this.IsMockObjectFromThisRepository(obj); if ((options & BackToRecordOptions.Expectations) == BackToRecordOptions.Expectations) { foreach (IExpectation allExpectationsForProxy in this.rootRecorder.GetAllExpectationsForProxy(obj)) { **this.rootRecorder.RemoveExpectation(allExpectationsForProxy);** } this.rootRecorder.RemoveAllRepeatableExpectationsForProxy(obj); } MockRepository.GetMockedObject(obj).ClearState(options); this.proxies[obj] = this.proxies[obj].BackToRecord(); foreach (IMockedObject dependentMock in MockRepository.GetMockedObject(obj).DependentMocks) { this.BackToRecord(dependentMock, options); } }

this.rootRecorder.RemoveExpectation(allExpectationsForProxy);

I would like to have access to the rootRecorder so I could be able to remove the expectations and set new ones.

The tests I run are "scenarios" so I don't care about how many times an method would be executed, I would like only to define the returning values and during my scenario execution the value changes. Also the system creates multiple threads during the execution so this make the testing infrastructure more complex.

@ayende
Copy link
Owner

ayende commented Apr 20, 2016

Why aren't you using the AAA model?
https://ayende.com/blog/3318/rhino-mocks-arrange-act-assert-syntax

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants