I have a code snippet to mock which is as follows inside a test method:
IManager imanager;
public classToBeTested(Manager manager)
{
imanager=manager;
}
public void methodToBeTested()
{
StringBuilder errorString = new StringBuilder();
List<RuleWrapper> allRules;
Dictionary<Guid, RuleConfiguration> allRuleConfigurations;
imanager.LoadAllRules(ref errorString, out allRuleConfigurations, out allRules);
SetGlobalRuleConfigurations(settingsManager, allRuleConfigurations, _globalRuleConfigurations);
}
How do I mock the behavior of mock by setting up out parameters:
I have the following snippet that I am trying to implement:
public void methodUsedForTesting()
{
StringBuilder errorString = new StringBuilder();
List<Rule> allRules = new List<Rule>();
Dictionary<Guid, RuleConfiguration> allRuleConfigurations = new Dictionary<Guid,RuleConfiguration>();
//Code for Initializing above Data members
RuleConfiguration ruleConfiguration1 = new RuleConfiguration("First");
RuleConfiguration ruleConfiguration2 = new RuleConfiguration("Second");
allRuleConfigurations.Add(ruleConfiguration1);
allRuleConfigurations.Add(ruleConfiguration2);
Rule rule1 = new Rule("First");
Rule rule2 = new Rule("Second");
allRules.add(rule1);
allRules.add(rule2);
Mock<Manager> mockManager = new Mock<Manager>();
mockManager.Setup(p => p.LoadAllRules(ref errorString, out allRuleConfigurations, out allRules));
classToBeTested classtest = new classToBeTested(mockManager.Object);
classtest.methodToBeTested();
}
What should be done so that the mock returns the data initialized by me and not the original behavior of that particular method?