public Implement ( object target, |
||
target | object |
/// The instance whose |
method | /// The method that is to be (re)implemented. /// | |
arguments | object | The target method's arguments. |
return | object |
public void SunnyDayPath() { IObjectFactory objectFactory = (IObjectFactory)mocks.CreateMock(typeof(IObjectFactory)); IConfigurableObjectDefinition configurableObjectDefinition = (IConfigurableObjectDefinition)mocks.CreateMock(typeof(IConfigurableObjectDefinition)); object expectedLookup = new object(); const string LookupObjectName = "foo"; Expect.Call(objectFactory.GetObject(LookupObjectName)).Return(expectedLookup); LookupMethodOverride ovr = new LookupMethodOverride("SunnyDayPath", LookupObjectName); MethodOverrides overrides = new MethodOverrides(); overrides.Add(ovr); Expect.Call(configurableObjectDefinition.MethodOverrides).Return(overrides); LookupMethodReplacer replacer = new LookupMethodReplacer(configurableObjectDefinition, objectFactory); mocks.ReplayAll(); MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod(); object lookup = replacer.Implement(this, method, new object[] {}); Assert.AreSame(expectedLookup, lookup); mocks.VerifyAll(); }
public void SunnyDayPath() { var objectFactory = A.Fake <IObjectFactory>(); var configurableObjectDefinition = A.Fake <IConfigurableObjectDefinition>(); object expectedLookup = new object(); const string LookupObjectName = "foo"; A.CallTo(() => objectFactory.GetObject(LookupObjectName)).Returns(expectedLookup); LookupMethodOverride ovr = new LookupMethodOverride("SunnyDayPath", LookupObjectName); MethodOverrides overrides = new MethodOverrides(); overrides.Add(ovr); A.CallTo(() => configurableObjectDefinition.MethodOverrides).Returns(overrides); LookupMethodReplacer replacer = new LookupMethodReplacer(configurableObjectDefinition, objectFactory); MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod(); object lookup = replacer.Implement(this, method, new object[] {}); Assert.AreSame(expectedLookup, lookup); }
public void SunnyDayPath() { var objectFactory = mocks.StrictMock<IObjectFactory>(); var configurableObjectDefinition = mocks.StrictMock<IConfigurableObjectDefinition>(); object expectedLookup = new object(); const string LookupObjectName = "foo"; Expect.Call(objectFactory.GetObject(LookupObjectName)).Return(expectedLookup); LookupMethodOverride ovr = new LookupMethodOverride("SunnyDayPath", LookupObjectName); MethodOverrides overrides = new MethodOverrides(); overrides.Add(ovr); Expect.Call(configurableObjectDefinition.MethodOverrides).Return(overrides); LookupMethodReplacer replacer = new LookupMethodReplacer(configurableObjectDefinition, objectFactory); mocks.ReplayAll(); MethodInfo method = (MethodInfo) MethodBase.GetCurrentMethod(); object lookup = replacer.Implement(this, method, new object[] {}); Assert.AreSame(expectedLookup, lookup); mocks.VerifyAll(); }