public void FindWithNoProjectOrSolution() { using (var fs = new DisposableFileSystem()) { fs.CreateFolder("src/project1") .CreateFile("src/project1/project1.csproj"); var finder = new ProjectFinder(fs.RootPath); Assert.Throws <FileNotFoundException>(() => finder.FindProjects()); } }
public async Task ChangePreWithBadFormatTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("5.0.8-beta")); var store = new ProjectStore(); var command = new PreCommand(GitHelper.CreateDefaultGitMock().Object); var context = new CommandContext(_console, Verbosity.Info); context.Directory = fs.RootPath; await Assert.ThrowsAsync <FormatException>(() => command.ExecuteAsync(context)); } }
public async Task ChangeVersionWithoutNoGitToolTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1")); var store = new ProjectStore(); var command = new MajorCommand(GitHelper.CreateDefaultGitMock().Object); var context = new CommandContext(_console, Verbosity.Info); context.Directory = fs.RootPath; context.Message = "test"; var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(context)); Assert.Equal("Unable to commit because git is not installed.", exception.Message); } }
public async Task ChangeVersionTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1")); var store = new ProjectStore(); var command = new SetCommand(GitHelper.CreateDefaultGitMock().Object); var context = new CommandContext(_console, Verbosity.Info); context.Directory = fs.RootPath; await command.ExecuteAsync(context, "3.0.1"); var project = store.Read(PathHelper.GetFile(fs, "src/Services/project1.csproj")); Assert.Equal("3.0.1", project.Version); } }
public async Task CreateCommitTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1")); var store = new ProjectStore(); var gitMock = GitHelper.CreateGitMock(true); var command = new MajorCommand(gitMock.Object); var context = new CommandContext(_console, Verbosity.Info); context.Directory = fs.RootPath; context.Message = "test"; await command.ExecuteAsync(context); gitMock.Verify(git => git.IsInstalled()); gitMock.Verify(git => git.RunCommandAsync(It.IsAny <CommandContext>(), It.Is <string>(args => args.Equals("commit -a -m \"test\"")))); } }