Previous method 'IConfigurationManager.get_AppSettings();' requires a return value or an exception to throw

12 views
Skip to first unread message

Charles Paquin

unread,
Oct 18, 2016, 2:55:37 AM10/18/16
to Rhino.Mocks
So im actually trying to make a certain method return a different value depending on the string parameter that it sends. I saw that you can use Repeat.Once() to do what i'm looking for. But, i get an "Previous method 'IConfigurationManager.get_AppSettings();' requires a return value or an exception to throw" even though the previous method returns a string already.
Here is my code

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


_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();
It Crashes at the second line.

Any help would be appreciated thanks in advance!

Reply all
Reply to author
Forward
0 new messages