requires a return value or an exception to throw

Skip to first unread message

Charles Paquin

Oct 18, 2016, 2:55:37 AM10/18/16
to Rhino.Mocks
Im trying to make a method return a different value when called with different parameter. I have read that .Repeat.once() was pretty much the only way to do this. But, when i try it, i get "requires a return value or an exception to throw" even though my previous method actually work and returns a value.

Here is my code

 BaseManager.IsMockDatabaseMode = true;
            _anomalieManager = MockRepository.GenerateMock<IAnomalieManager>();
            _configurationManager = MockRepository.GenerateMock<IConfigurationManager>();
            _itineraireManager = MockRepository.GenerateMock<IItineraireManager>();
            manager = new SynchroManager(_anomalieManager, _configurationManager, _itineraireManager);

        public void SynchronizeFlights_Success()
            _configurationManager.Stub(p => p.AppSettings.Get(Arg<string>.Matches(i => i == "CrewCodes"))).Return("Charles").Repeat.Once();
            _configurationManager.Stub(a => a.AppSettings.Get(Arg<string>.Matches(s => s == "NbJoursAvantAnomalie"))).Return("1").Repeat.Once();

Any help would be appreciated


Oct 18, 2016, 7:21:31 AM10/18/16
to Rhino.Mocks
Why not use .Do? It accepts the argument and returns anything you want.
In your case it will be:
.Do(new Func<string,string>(arg=>{put your logic here}).Repeat.Any
Reply all
Reply to author
0 new messages