public void Setup()
        {
            if (_referenceRepository is null)
            {
                _referenceRepository = new ReferenceRepository();
            }
            else
            {
                _referenceRepository.Reset();
            }

            _file = Substitute.For <FileBase>();
            _file.ReadAllText(_commitMessagePath, _encoding).Returns(_commitMessage);
            _file.ReadAllText(_mergeMessagePath, _encoding).Returns(_mergeMessage);
            _directory = Substitute.For <DirectoryBase>();

            var path = Substitute.For <PathBase>();

            path.Combine(Arg.Any <string>(), Arg.Any <string>()).Returns(x => Path.Combine((string)x[0], (string)x[1]));

            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(_file);
            _fileSystem.Directory.Returns(_directory);
            _fileSystem.Path.Returns(path);

            _manager = new CommitMessageManager(_workingDirGitDir, _encoding, _fileSystem, overriddenCommitMessage: null);
        }
        public void AmendState_should_be_false_if_file_contains(string amendText)
        {
            _file.Exists(_amendSaveStatePath).Returns(true);
            _file.ReadAllText(_amendSaveStatePath).Returns(amendText);

            AppSettings.RememberAmendCommitState = true;
            _manager.AmendState.Should().BeFalse();
        }
        public void Setup()
        {
            _file = Substitute.For <FileBase>();
            _file.ReadAllText(_commitMessagePath, _encoding).Returns(_commitMessage);
            _file.ReadAllText(_mergeMessagePath, _encoding).Returns(_mergeMessage);

            var path = Substitute.For <PathBase>();

            path.Combine(Arg.Any <string>(), Arg.Any <string>()).Returns(x => Path.Combine((string)x[0], (string)x[1]));

            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(_file);
            _fileSystem.Path.Returns(path);

            _manager = CommitMessageManager.TestAccessor.Construct(_workingDirGitDir, _encoding, _fileSystem);
        }
        public void LoadGitCommitTemplate_should_load_file_content()
        {
            const string relativePath = "./template.txt";
            string       fullPath     = Path.GetFullPath(Path.Combine(_workingDir, relativePath));

            _module.WorkingDir.Returns(_workingDir);
            _fullPathResolver.Resolve(relativePath).Returns(fullPath);
            _module.GetEffectiveSetting("commit.template").Returns(relativePath);
            _file.Exists(fullPath).Returns(true);
            _file.ReadAllText(fullPath).Returns("line1");

            var content = _manager.LoadGitCommitTemplate();

            content.Should().NotBeEmpty();
        }