public void SetVersion_Full_Test_Without_Version_File() { // Arrange: var fileSystem = new InMemoryFileSystem(new Dictionary<string, string> { { @"|Dev|Applications|Websites.sln".Path(), TestData.SolutionContent }, { @"|Dev|Applications|WebApi|Properties|AssemblyInfo.cs".Path(), TestData.AssemblyInfoContent_WebApi }, { @"|Dev|BusinessLogic|Properties|AssemblyInfo.cs".Path(), TestData.AssemblyInfoContent_BusinessLogic } }); var versioner = new Versioner(fileSystem, new ConsoleOutput()); // Act: versioner.SetVersion("|Dev|Applications|Websites.sln".Path(), "0.9.7", "BETA"); // Assert: string assemblyInfoWebApi = fileSystem.ReadAllText(@"|Dev|Applications|WebApi|Properties|AssemblyInfo.cs".Path()); string assemblyInfoBusinessLogic = fileSystem.ReadAllText(@"|Dev|BusinessLogic|Properties|AssemblyInfo.cs".Path()); // They all should have the default version and the additional info StringAssert.Contains(@"AssemblyFileVersionAttribute(@""0.9.7"")", assemblyInfoWebApi); StringAssert.Contains(@"AssemblyVersionAttribute(@""0.9.7"")", assemblyInfoWebApi); StringAssert.Contains(@"AssemblyFileVersionAttribute(@""0.9.7"")", assemblyInfoBusinessLogic); StringAssert.Contains(@"AssemblyVersionAttribute(@""0.9.7"")", assemblyInfoBusinessLogic); StringAssert.Contains(@"AssemblyInformationalVersionAttribute(@""BETA"")", assemblyInfoWebApi); StringAssert.Contains(@"AssemblyInformationalVersionAttribute(@""BETA"")", assemblyInfoBusinessLogic); }
public static int Main(string[] args) { var options = new CommandLineOptions(); if (Parser.Default.ParseArguments(args, options)) { try { var versioner = new Versioner(new FileSystem(), new ConsoleOutput()); versioner.SetVersion(options.ProjectPath, options.DefaultVersion, options.AdditionalInfo); return 0; } catch (Exception exception) { Console.WriteLine(exception); } } return -1; }
public void SetVersion_Should_Throw_ArgumentException_If_Project_Path_Is_Invalid() { var versioner = new Versioner(Mock.Of<IFileSystem>(), new ConsoleOutput()); versioner.SetVersion(@"Not-A-Valid-Project-File.txt", "1.0", null); }