private static void AddRecordingRuleWhenRecorderIsSpecified(ISelfInitializingFakeRecorder recorder, FakeManager fake, WrappedObjectRule wrapperRule) { if (recorder != null) { fake.AddRuleFirst(new SelfInitializationRule(wrapperRule, recorder)); } }
private static void AddRecordingRuleWhenRecorderIsSpecified(ISelfInitializingFakeRecorder recorder, FakeManager fake, WrappedObjectRule wrapperRule) { if (recorder != null) { fake.AddRuleFirst(new SelfInitializationRule(wrapperRule, recorder)); } }
/// <summary> /// Configures the specified faked object to wrap the specified instance. /// </summary> /// <param name="fakedObject">The faked object to configure.</param> /// <param name="wrappedInstance">The instance to wrap.</param> /// <param name="recorder">The recorder to use, null if no recording should be made.</param> public void ConfigureFakeToWrap(object fakedObject, object wrappedInstance, ISelfInitializingFakeRecorder recorder) { var fake = Fake.GetFakeManager(fakedObject); var wrapperRule = CreateAndAddWrapperRule(wrappedInstance, fake); AddRecordingRuleWhenRecorderIsSpecified(recorder, fake, wrapperRule); }
/// <summary> /// Configures the specified faked object to wrap the specified instance. /// </summary> /// <param name="fakedObject">The faked object to configure.</param> /// <param name="wrappedInstance">The instance to wrap.</param> /// <param name="recorder">The recorder to use, null if no recording should be made.</param> public void ConfigureFakeToWrap(object fakedObject, object wrappedInstance, ISelfInitializingFakeRecorder recorder) { var fake = Fake.GetFakeManager(fakedObject); var wrapperRule = CreateAndAddWrapperRule(wrappedInstance, fake); AddRecordingRuleWhenRecorderIsSpecified(recorder, fake, wrapperRule); }
/// <summary> /// Creates a self initializing fake wrapper wrapping the specified object. The /// recorder is used to record calls so that they are only made to the wrapped instance /// if they've not already been recorded. /// </summary> /// <typeparam name="T">The type of the fake.</typeparam> /// <param name="wrappedInstance">The wrapped.</param> /// <param name="recorder">The recorder.</param> /// <returns>The faked object.</returns> public static T Fake <T>(T wrappedInstance, ISelfInitializingFakeRecorder recorder) { Guard.IsNotNull(wrappedInstance, "wrappedInstance"); Guard.IsNotNull(recorder, "recorder"); var fake = FakeItEasy.Fake.GetFakeObject(CreateFake <T>(null)); fake.AddRule(new SelfInitializationRule(new WrappedObjectRule(wrappedInstance), recorder)); return((T)fake.Object); }
internal static FakeOptions HasRecorder(this IArgumentConstraintManager<FakeOptions> scope, ISelfInitializingFakeRecorder recorder) { return scope.Matches(x => recorder.Equals(x.Wrapper.Recorder), "Specified recorder"); }
internal static FakeOptions HasRecorder(this IArgumentConstraintManager <FakeOptions> scope, ISelfInitializingFakeRecorder recorder) { return(scope.Matches(x => recorder.Equals(x.SelfInitializedFakeRecorder), "Specified recorder")); }
/// <summary> /// Initializes a new instance of the <see cref="SelfInitializationRule"/> class. /// </summary> /// <param name="wrappedRule">The wrapped rule.</param> /// <param name="recorder">The recorder.</param> public SelfInitializationRule(IFakeObjectCallRule wrappedRule, ISelfInitializingFakeRecorder recorder) { this.wrappedRule = wrappedRule; this.recorder = recorder; }
public SelfInitializationRuleTests() { this.wrappedRule = A.Fake<IFakeObjectCallRule>(); this.recorder = A.Fake<ISelfInitializingFakeRecorder>(); }
public void Setup() { this.wrappedRule = A.Fake <IFakeObjectCallRule>(); this.recorder = A.Fake <ISelfInitializingFakeRecorder>(); }
internal static ArgumentConstraint <FakeOptions> HasRecorder(this ArgumentConstraintScope <FakeOptions> scope, ISelfInitializingFakeRecorder recorder) { return(ArgumentConstraint.Create(scope, x => recorder.Equals(x.SelfInitializedFakeRecorder), "Specified recorder")); }
public IFakeOptions <T> RecordedBy(ISelfInitializingFakeRecorder recorder) { this.Recorder = recorder; return(this.fakeOptions); }
IFakeOptions IFakeOptionsForWrappers.RecordedBy(ISelfInitializingFakeRecorder fakeRecorder) { return((IFakeOptions)this.RecordedBy(fakeRecorder)); }
public SelfInitializationRuleTests() { this.wrappedRule = A.Fake <IFakeObjectCallRule>(); this.recorder = A.Fake <ISelfInitializingFakeRecorder>(); }
public IFakeOptionsBuilder <T> RecordedBy(ISelfInitializingFakeRecorder recorder) { this.Options.SelfInitializedFakeRecorder = recorder; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="SelfInitializationRule"/> class. /// </summary> /// <param name="wrappedRule">The wrapped rule.</param> /// <param name="recorder">The recorder.</param> public SelfInitializationRule(IFakeObjectCallRule wrappedRule, ISelfInitializingFakeRecorder recorder) { this.wrappedRule = wrappedRule; this.recorder = recorder; }
public void Setup() { this.wrappedRule = A.Fake<IFakeObjectCallRule>(); this.recorder = A.Fake<ISelfInitializingFakeRecorder>(); }