public static void CreateFromInitializedRepository( IRecordedCallRepository repository, Func <IService> serviceFactory, SelfInitializingFake <IService> fake) { "Given a saved call repository" .x(() => repository = A.Fake <IRecordedCallRepository>()); "And the repository has been initialized" .x(() => A.CallTo(() => repository.Load()).Returns(Enumerable.Empty <RecordedCall>())); "And a service factory" .x(() => serviceFactory = A.Fake <Func <IService> >()); "When I create a self-initializing fake" .x(() => fake = SelfInitializingFake <IService> .For(serviceFactory, repository)); "Then the factory is not invoked" .x(() => A.CallTo(serviceFactory).MustNotHaveHappened()); }
public static void CreateFromDerivedFactoryType( IRecordedCallRepository repository, Func <Service> serviceFactory, SelfInitializingFake <IService> fake) { "Given a saved call repository" .x(() => repository = A.Fake <IRecordedCallRepository>()); "And the repository has not been initialized" .x(() => A.CallTo(() => repository.Load()).Returns(null)); "And a service factory that creates a derived type" .x(() => serviceFactory = A.Fake <Func <Service> >()); "When I create a self-initializing fake" .x(() => fake = SelfInitializingFake <IService> .For <IService>(serviceFactory, repository)); "Then the factory is invoked to create the service" .x(() => A.CallTo(serviceFactory).MustHaveHappened()); }