Esempio n. 1
0
        protected override void beforeEach()
        {
            const string projectName = "TestProject";

            theInput = new NewCommandInput
            {
                ProjectName = projectName
            };
            fileSystem      = MockRepository.GenerateStub <IFileSystem>();
            zipService      = MockRepository.GenerateStub <IZipFileService>();
            keywordReplacer = MockRepository.GenerateStub <IKeywordReplacer>();
            processFactory  = MockRepository.GenerateStub <IProcessFactory>();

            fileSystem.Stub(x => x.FindFiles(Arg <string> .Is.Anything, Arg <FileSet> .Is.NotNull)).Return(new string[0]);

            ClassUnderTest.FileSystem = fileSystem;
            ClassUnderTest.ZipService = zipService;
        }
Esempio n. 2
0
        public void to_template_choices_basics()
        {
            var input = new NewCommandInput
            {
                SolutionName  = "MyCompany.NewThing",
                RippleFlag    = FeedChoice.Edge,
                ShortNameFlag = "NewThang",
                NoTestsFlag   = true,
                OptionsFlag   = new string[] { "a", "b", "c" }
            };

            var choices = input.ToTemplateChoices();

            choices.Category.ShouldEqual("new");
            choices.ProjectName.ShouldEqual(input.SolutionName);
            choices.ProjectType.ShouldEqual(input.Profile);
            choices.Options.ShouldHaveTheSameElementsAs("a", "b", "c");
        }
Esempio n. 3
0
        public void adds_in_the_testing_request_if_app_and_tests_are_selected()
        {
            var input = new NewCommandInput
            {
                SolutionName = "NewThing",
                AppFlag      = true,
                TestsFlag    = true
            };

            var request        = NewCommand.BuildTemplateRequest(input);
            var testingRequest = request.TestingProjects.Single();

            testingRequest.ShouldNotBeNull();
            testingRequest.OriginalProject.ShouldEqual("NewThing");
            testingRequest.Name.ShouldEqual("NewThing.Testing");
            testingRequest.Template.ShouldEqual("baseline");

            testingRequest.Alterations.Single().ShouldEqual("unit-testing");
        }
Esempio n. 4
0
        public void Execute(NewCommandInput input, TemplatePlan plan, Action <TemplatePlanContext> continuation)
        {
            var context = new TemplatePlanContext
            {
                Input   = input,
                TempDir = createTempDir()
            };

            _fileSystem.CreateDirectory(context.TempDir);

            var targetPath = input.ProjectName;

            if (input.OutputFlag.IsNotEmpty())
            {
                targetPath = input.OutputFlag;
            }
            else if (input.SolutionFlag.IsNotEmpty())
            {
                targetPath = _fileSystem.GetDirectory(input.SolutionFlag);
            }

            context.TargetPath = Path.Combine(Environment.CurrentDirectory, targetPath);

            plan.Preview(context);

            try
            {
                plan
                .Steps
                .Each(step => step.Execute(context));
            }
            catch (Exception exc)
            {
                context.RegisterError(exc.Message);
                context.RegisterError(exc.StackTrace);
            }

            continuation(context);
            _fileSystem.DeleteDirectory(context.TempDir);
        }
Esempio n. 5
0
        public void Execute(NewCommandInput input, TemplatePlan plan, Action<TemplatePlanContext> continuation)
        {
            var context = new TemplatePlanContext
                              {
                                  Input = input,
                                  TempDir = createTempDir()
                              };

            _fileSystem.CreateDirectory(context.TempDir);

            var targetPath = input.ProjectName;
            if(input.OutputFlag.IsNotEmpty())
            {
                targetPath = input.OutputFlag;
            }
            else if(input.SolutionFlag.IsNotEmpty())
            {
                targetPath = _fileSystem.GetDirectory(input.SolutionFlag);
            }

            context.TargetPath = Path.Combine(Environment.CurrentDirectory, targetPath);

            plan.Preview(context);

            try
            {
                plan
                    .Steps
                    .Each(step => step.Execute(context));
            }
            catch (Exception exc)
            {
                context.RegisterError(exc.Message);
                context.RegisterError(exc.StackTrace);
            }

            continuation(context);
            _fileSystem.DeleteDirectory(context.TempDir);
        }