public BuildFeatureFixture( FakeFileSystem fileSystem = null, FakeEnvironment environment = null, TestContainerConfigurator bootstrapper = null, FakeLog log = null, FakeConsole console = null, IModuleSearcher moduleSearcher = null) { Environment = environment ?? FakeEnvironment.CreateUnixEnvironment(); FileSystem = fileSystem ?? new FakeFileSystem(Environment); Bootstrapper = bootstrapper ?? new TestContainerConfigurator(); ScriptEngine = new FakeScriptEngine(); Debugger = new FakeDebugger(); Log = log ?? new FakeLog(); Console = console ?? new FakeConsole(); ModuleSearcher = moduleSearcher ?? Substitute.For <IModuleSearcher>(); Processor = Substitute.For <IScriptProcessor>(); // Create working directory. FileSystem.CreateDirectory(Environment.WorkingDirectory); // Set the default script SetScript("/Working/build.cake", GetDefaultScriptContent()); Bootstrapper.RegisterOverrides(registrar => { registrar.RegisterInstance(FileSystem).As <IFileSystem>(); registrar.RegisterInstance(Environment).As <ICakeEnvironment>(); registrar.RegisterInstance(ScriptEngine).As <IScriptEngine>(); registrar.RegisterInstance(Debugger).As <ICakeDebugger>(); registrar.RegisterInstance(Log).As <ICakeLog>(); registrar.RegisterInstance(Processor).As <IScriptProcessor>(); }); }
public ProgramFixture() { Bootstrapper = new TestContainerConfigurator(); Environment = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(Environment); Log = new FakeLog(); Console = new FakeConsole(); ModuleSearcher = Substitute.For <IModuleSearcher>(); Builder = new BuildFeatureFixture(FileSystem, Environment, Bootstrapper, Log, Console, ModuleSearcher); // CLI overrides Overrides = new List <Action <ContainerBuilder> >() { builder => builder.RegisterInstance(Bootstrapper).As <IContainerConfigurator>(), builder => builder.RegisterInstance(Environment).As <ICakeEnvironment>(), builder => builder.RegisterInstance(FileSystem).As <IFileSystem>(), builder => builder.RegisterInstance(Log).As <ICakeLog>(), builder => builder.RegisterInstance(Console).As <IConsole>(), builder => builder.RegisterInstance(ModuleSearcher).As <IModuleSearcher>(), builder => builder.RegisterInstance(Builder).As <IBuildFeature>() }; }