public void Stubs_do_not_verify_their_expectations() { //This is a legacy point. //I recommend the AssertWasCalled syntax over the VerifyAll. var service = MockRepository.GenerateStub<IGameResultsService>(); var game = new Game(); service.Expect(s => s.GetMagicNumber(Arg<string>.Is.Anything)).Return(4); game.IgnoreTheService(service); //This will silently pass, as if Game were meeting your expectations. //Falsely passing test. service.VerifyAllExpectations(); }
public void Only_mocks_verify_their_expectations() { //This is a legacy point. //I recommend the AssertWasCalled syntax over the VerifyAll. var service = MockRepository.GenerateMock<IGameResultsService>(); var game = new Game(); service.Expect(m => m.GetMagicNumber(Arg<string>.Is.Anything)).Return(4); game.IgnoreTheService(service); //This should (and does) throw an expectation violation. //Correctly failing test. service.VerifyAllExpectations(); }
public void Stubs_now_apply_AssertWasCalled() { //In prior versions of Rhino Mocks, AssertWasCalled and //AssertWasNotCalled on stubs would silently pass. var game = new Game(); var service = MockRepository.GenerateStub<IGameResultsService>(); game.IgnoreTheService(service); //This should (and does) throw an expectation violation in 3.5+. //Correctly failing test. service.AssertWasCalled(s => s.GetMagicNumber(Arg<string>.Is.Anything)); }