/// <summary> /// Gets an object that provides a fluent interface syntax for configuring /// the fake object. /// </summary> /// <typeparam name="TFake">The type of the fake object.</typeparam> /// <param name="fakedObject">The fake object to configure.</param> /// <returns>A configuration object.</returns> /// <exception cref="ArgumentNullException">The fakedObject was null.</exception> /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception> public static IFakeConfiguration <TFake> Configure <TFake>(TFake fakedObject) { Guard.IsNotNull(fakedObject, "fakedObject"); var expressionCallRuleFactory = ServiceLocator.Current.Resolve <ExpressionCallRule.Factory>(); return(new FakeConfiguration <TFake>(Fake.GetFakeObject(fakedObject), expressionCallRuleFactory)); }
/// <summary> /// Gets all the calls made to the specified fake object. /// </summary> /// <typeparam name="TFake">The type of the faked object.</typeparam> /// <param name="fakedObject">The faked object.</param> /// <returns>A collection containing the calls to the object.</returns> /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception> public static CallCollection <TFake> GetCalls <TFake>(TFake fakedObject) { Guard.IsNotNull(fakedObject, "fakedObject"); var factory = ServiceLocator.Current.Resolve <ICallCollectionFactory>(); return(factory.CreateCallCollection <TFake>(Fake.GetFakeObject(fakedObject))); }
/// <summary> /// Gets all the calls made to the specified fake object. /// </summary> /// <param name="fakedObject">The faked object.</param> /// <returns>A collection containing the calls to the object.</returns> /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception> public static IEnumerable <ICompletedFakeObjectCall> GetCalls(object fakedObject) { Guard.IsNotNull(fakedObject, "fakedObject"); return(Fake.GetFakeObject(fakedObject).RecordedCallsInScope); }
/// <summary> /// Asserts on the faked object. /// </summary> /// <returns>A fake assertions object.</returns> private IFakeAssertions <T> Assert() { return(ServiceLocator.Current.Resolve <IFakeAssertionsFactory>().CreateAsserter <T>(Fake.GetFakeObject(this.FakedObject))); }
/// <summary> /// Gets all the calls made to the specified fake object. /// </summary> /// <typeparam name="TFake">The type of the faked object.</typeparam> /// <param name="fakedObject">The faked object.</param> /// <returns>A collection containing the calls to the object.</returns> /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception> public static CallCollection <TFake> GetCalls <TFake>(TFake fakedObject) where TFake : class { Guard.IsNotNull(fakedObject, "fakedObject"); return(new CallCollection <TFake>(Fake.GetFakeObject(fakedObject))); }
/// <summary> /// Gets an object that provides a fluent interface syntax for configuring /// the fake object. /// </summary> /// <typeparam name="TFake">The type of the fake object.</typeparam> /// <param name="fakedObject">The fake object to configure.</param> /// <returns>A configuration object.</returns> /// <exception cref="ArgumentNullException">The fakedObject was null.</exception> /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception> public static IFakeConfiguration <TFake> Configure <TFake>(TFake fakedObject) where TFake : class { Guard.IsNotNull(fakedObject, "fakedObject"); return(new FakeConfiguration <TFake>(Fake.GetFakeObject(fakedObject))); }
/// <summary> /// Gets a configuration object allowing for further configuration of /// any calll to the specified faked object. /// </summary> /// <typeparam name="TFake">The type of fake object.</typeparam> /// <param name="fakedObject">The faked object to configure.</param> /// <returns>A configuration object.</returns> public static IAnyCallConfiguration CallTo <TFake>(TFake fakedObject) { var configurationFactory = ServiceLocator.Current.Resolve <IStartConfigurationFactory>(); return(configurationFactory.CreateConfiguration <TFake>(Fake.GetFakeObject(fakedObject)).AnyCall()); }