public void When_modifying_the_assembly_version_it_should_modify_it_and_save_it() { // ---------------------------------------------------------------- // ARRANGE //----------------------------------------------------------------- string assemblyInfoFile = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\AssemblyInfo_1.txt"; var parser = new AssemblyInfoWriter(assemblyInfoFile); // ---------------------------------------------------------------- // ACT //----------------------------------------------------------------- parser.ModifyAssemblyVersionTo("1.1.1.1"); // ---------------------------------------------------------------- // ASSERT //----------------------------------------------------------------- bool parserReplacedValue = FindInFile(AssemblyInfoContext.InfoVersionBeginText + "1.1.1.1" + AssemblyInfoContext.LastPartOfLine, assemblyInfoFile); Assert.IsTrue(parserReplacedValue); }
private void ModifyAssemblyVersion(AssemblyInfoWriter writer, AssemblyInfoReader reader) { Log.LogMessage(MessageImportance.Normal, string.Format("Modifying AssemblyVersion with pattern: {0}", AssemblyVersionPattern)); Log.LogMessage(MessageImportance.Normal, string.Format("AssemblyInfo file: : {0}", AssemblyInfoPath)); try { string newValue = new PatternBasedParser().Replace(reader.GetAssemblyVersion(), AssemblyVersionPattern); writer.ModifyAssemblyVersionTo(newValue); } catch (ApplicationException exception) { Log.LogErrorFromException(exception); } }
public void When_the_file_is_set_to_readonly_it_should_still_modify_it() { // ---------------------------------------------------------------- // ARRANGE //----------------------------------------------------------------- string assemblyInfoFile = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ReadOnlyAssemblyInfo.txt"; new FileInfo(assemblyInfoFile) {IsReadOnly = true}; var parser = new AssemblyInfoWriter(assemblyInfoFile); // ---------------------------------------------------------------- // ACT //----------------------------------------------------------------- parser.ModifyAssemblyFileVersionTo("2.2.2.2"); parser.ModifyAssemblyVersionTo("1.1.1.1"); // ---------------------------------------------------------------- // ASSERT //----------------------------------------------------------------- bool parserReplacedAssemblyFileVersionValue = FindInFile(AssemblyInfoContext.FileVersionBeginText + "2.2.2.2" + AssemblyInfoContext.LastPartOfLine, assemblyInfoFile); bool parserReplacedAssemblyVersionValue = FindInFile(AssemblyInfoContext.InfoVersionBeginText + "1.1.1.1" + AssemblyInfoContext.LastPartOfLine, assemblyInfoFile); Assert.IsTrue(parserReplacedAssemblyFileVersionValue); Assert.IsTrue(parserReplacedAssemblyVersionValue); Assert.IsTrue(new FileInfo(assemblyInfoFile).IsReadOnly); }