private async Task SaveGitIgnoreFile(string destination, GitignoreFile gitIgnoreFile)
 {
     try
     {
         await _gitignoreFileWriter.WriteToFileAsync(destination, gitIgnoreFile.Content);
     }
     catch (Exception e)
     {
         throw new ArgException($"Destination path {destination} is invalid or there were " +
                                "problem with file access", e);
     }
 }
Exemplo n.º 2
0
        public async Task <int> HandleCommandAsync(GitignoreGetCommand command)
        {
            GitignoreFile gitIgnoreFile = await _githubService.GetIgnoreFile(command.NameOption.Value());

            if (GitignoreFile.Empty == gitIgnoreFile)
            {
                throw new ArgException($"Name {command.NameOption.Value()} is not correct .gitignore file name");
            }

            await _gitignoreFileWriter.WriteToFileAsync(command.DestinationOption.Value(), gitIgnoreFile.Content);

            return(ReturnCodes.Success);
        }
        public void MergeShouldReturnOnlyFileWhenOnlyOneExist()
        {
            // Arrange
            var mergeStrategy = new SimpleMergeStrategy();
            var file          = new GitignoreFile("name", "content");
            var files         = new[]
            {
                file
            };

            // Act
            var result = mergeStrategy.Merge(files);

            // Assert
            result
            .Should()
            .Be(file);
        }