Beispiel #1
0
        public void FindTemplatePathWhenDefaultConfigFileDoesNotHaveTemplateProperty()
        {
            // ARRANGE
            var content = @"{
                'Information': [
                'This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.',
                'To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.',
                'dotnet lambda help',
                'All the command line options for the Lambda command can be specified in this file.'
                ],
                'profile': 'default',
                'region': 'us-west-2',
                'configuration': 'Release',
                'framework': 'netcoreapp3.1',
                's3-prefix': 'AWSServerless1/'
            }";

            var tempDir = Path.Combine(Path.GetTempPath(), GetRandomDirectoryName());

            CreateCustomerApplication(tempDir);
            var templateFinder       = new CloudFormationTemplateFinder(new FileManager(), new DirectoryManager());
            var projectRootDirectory = Path.Combine(tempDir, "Codebase", "Src", "MyServerlessApp");

            CreateFile(Path.Combine(projectRootDirectory, "Configurations", "aws-lambda-tools-defaults.json"));
            File.WriteAllText(Path.Combine(projectRootDirectory, "Configurations", "aws-lambda-tools-defaults.json"), content);

            // ACT
            var templatePath = templateFinder.FindCloudFormationTemplate(projectRootDirectory);

            // ASSERT
            var expectedPath = Path.Combine(projectRootDirectory, "serverless.template");

            Assert.Equal(expectedPath, templatePath);
            Assert.True(File.Exists(templatePath));
        }
Beispiel #2
0
        public void DetermineProjectRootDirectoryTest()
        {
            // ARRANGE
            var tempDir = Path.Combine(Path.GetTempPath(), GetRandomDirectoryName());

            CreateCustomerApplication(tempDir);
            var templateFinder = new CloudFormationTemplateFinder(new FileManager(), new DirectoryManager());

            // ACT and ASSERT
            var expectedRoot = Path.Combine(tempDir, "Codebase", "Src", "MyServerlessApp");

            Assert.Equal(expectedRoot, templateFinder.DetermineProjectRootDirectory(Path.Combine(expectedRoot, "Models", "Cars.cs")));
            Assert.Equal(expectedRoot, templateFinder.DetermineProjectRootDirectory(Path.Combine(expectedRoot, "BusinessLogic", "Logic2.cs")));
            Assert.Equal(expectedRoot, templateFinder.DetermineProjectRootDirectory(Path.Combine(expectedRoot, "Program.cs")));
            Assert.Equal(expectedRoot, templateFinder.DetermineProjectRootDirectory(Path.Combine(expectedRoot, "MyServerlessApp.csproj")));
        }
Beispiel #3
0
        public void FindTemplateWithoutDefaultConfigFile()
        {
            // ARRANGE
            var tempDir = Path.Combine(Path.GetTempPath(), GetRandomDirectoryName());

            CreateCustomerApplication(tempDir);
            var templateFinder       = new CloudFormationTemplateFinder(new FileManager(), new DirectoryManager());
            var projectRootDirectory = Path.Combine(tempDir, "Codebase", "Src", "MyServerlessApp");

            // ACT
            var templatePath = templateFinder.FindCloudFormationTemplate(projectRootDirectory);

            // ASSERT
            var expectedPath = Path.Combine(projectRootDirectory, "serverless.template");

            Assert.Equal(expectedPath, templatePath);
            Assert.True(File.Exists(templatePath));
        }