Esempio n. 1
0
        ICommand CreateInstance(Type type, IVariables variables, ILog log)
        {
            var fileSystem        = CalamariPhysicalFileSystem.GetPhysicalFileSystem();
            var commandLineRunner = new CommandLineRunner(ConsoleLog.Instance, variables);
            var substituteInFiles = new SubstituteInFiles(fileSystem, new FileSubstituter(log, fileSystem), variables);
            var extractPackages   = new ExtractPackage(new CombinedPackageExtractor(log), fileSystem, variables, log);

            if (type == typeof(PlanCommand))
            {
                return(new PlanCommand(log, variables, fileSystem, commandLineRunner, substituteInFiles, extractPackages));
            }

            if (type == typeof(ApplyCommand))
            {
                return(new ApplyCommand(log, variables, fileSystem, commandLineRunner, substituteInFiles, extractPackages));
            }

            if (type == typeof(DestroyCommand))
            {
                return(new DestroyCommand(log, variables, fileSystem, commandLineRunner, substituteInFiles, extractPackages));
            }

            if (type == typeof(DestroyPlanCommand))
            {
                return(new DestroyPlanCommand(log, variables, fileSystem, commandLineRunner, substituteInFiles, extractPackages));
            }

            throw new ArgumentException();
        }
        public void SetUp()
        {
            fileSystem = Substitute.For <ICalamariFileSystem>();
            fileSystem.RemoveInvalidFileNameChars(Arg.Any <string>()).Returns(c => c.Arg <string>().Replace("!", ""));

            variables      = new CalamariVariables();
            extractPackage = new ExtractPackage(Substitute.For <ICombinedPackageExtractor>(), fileSystem, variables, new InMemoryLog());
        }