Example #1
0
        public async Task GetTemplates_Should_Return_AllTemplates()
        {
            // Arrange
            var executor = new Mock <ICommandExecutor>();

            executor.Setup(expression: c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1))
            .ReturnsAsync(new CommandResult
            {
                ExitCode = 0,
                Output   = @"
-------------------  --------  ---------  ---------
My Template          myt       lang       tags
My Other Template    myot      otherlang  othertags
",
            }
                          );
            var controller = new NewController(executor.Object);

            // Act
            var result = await controller.GetTemplates();

            // Assert
            var okResult  = Assert.IsType <OkObjectResult>(result);
            var templates = Assert.IsType <TemplateDictionary>(okResult.Value);

            templates.Count.Should().Be(2);
            templates.Keys.Should().Contain("myt");
            templates["myt"].Name.Should().Be("My Template");
            templates["myt"].Languages.Should().Be("lang");
            templates["myt"].Tags.Should().Be("tags");
            templates.Keys.Should().Contain("myot");
            templates["myot"].Name.Should().Be("My Other Template");
            templates["myot"].Languages.Should().Be("otherlang");
            templates["myot"].Tags.Should().Be("othertags");
        }