/// <summary> /// Add additional interfaces to the builder. /// </summary> /// <typeparam name="T">The proxy type.</typeparam> /// <param name="builder">The <see cref="IFakeOptionsBuilder{T}"/>.</param> protected virtual void Build <T>(IFakeOptionsBuilder <T> builder) { foreach (var i in this.additionalInterfaces) { builder.Implements(i); } }
/// <summary> /// Makes the fake default to calling base methods, so long as they aren't abstract. /// </summary> /// <typeparam name="T">The type of fake object.</typeparam> /// <param name="options">The configuration.</param> /// <returns>A configuration object.</returns> public static IFakeOptionsBuilder <T> CallsBaseMethods <T>(this IFakeOptionsBuilder <T> options) { Guard.AgainstNull(options, "options"); return(options.ConfigureFake(fake => A.CallTo(fake) .Where(call => !call.Method.IsAbstract) .CallsBaseMethod())); }
public void CreateFake_should_pass_options_builder_that_returns_itself_for_any_call(Func <IFakeOptionsBuilder <Foo>, IFakeOptionsBuilder <Foo> > call) { // Arrange IFakeOptionsBuilder <Foo> builderPassedToAction = null; // Act this.creator.CreateFake <Foo>(x => { builderPassedToAction = x; }); // Assert Assert.That(call.Invoke(builderPassedToAction), Is.SameAs(builderPassedToAction)); }
/// <summary> /// Makes the fake strict, this means that any call to the fake /// that has not been explicitly configured will throw an exception. /// </summary> /// <typeparam name="T">The type of fake object.</typeparam> /// <param name="options">The configuration.</param> /// <returns>A configuration object.</returns> public static IFakeOptionsBuilder <T> Strict <T>(this IFakeOptionsBuilder <T> options) { Guard.AgainstNull(options, "options"); Action <IFakeObjectCall> thrower = call => { throw new ExpectationException("Call to non configured method \"{0}\" of strict fake.".FormatInvariant(call.Method.Name)); }; return(options.ConfigureFake(fake => A.CallTo(fake).Invokes(thrower))); }
private void ApplyOptions <T>(IFakeOptionsBuilder <T> options) { if (this._strict) { options.Strict(); } if (this._onFakeCreated != null) { options.OnFakeCreated(x => this._onFakeCreated(x)); } }
public static void GenericFakeOptionsBuilderDefaultPriority( IFakeOptionsBuilder builder, Priority priority) { "Given a fake options builder that does not override priority" .x(() => builder = new SomeClassOptionsBuilder()); "When I get the priority" .x(() => priority = builder.Priority); "Then it is the default priority" .x(() => priority.Should().Be(Priority.Default)); }
public FakeWrapperConfigurator(IFakeOptionsBuilder <T> fakeOptionsBuilder, object wrappedObject) { this.fakeOptionsBuilder = fakeOptionsBuilder; this.WrappedObject = wrappedObject; }