public void When_modifying_the_file_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.ModifyAssemblyFileVersionTo("2.2.2.2"); // ---------------------------------------------------------------- // ASSERT //----------------------------------------------------------------- bool parserReplacedValue = FindInFile(AssemblyInfoContext.FileVersionBeginText + "2.2.2.2" + AssemblyInfoContext.LastPartOfLine, assemblyInfoFile); Assert.IsTrue(parserReplacedValue); }
private void ModifyAssemblyFileVersion(AssemblyInfoWriter writer, AssemblyInfoReader reader) { Log.LogMessage(MessageImportance.Normal, string.Format("Modifying AssemblyFileVersion with pattern: {0}", AssemblyVersionPattern)); try { string newValue = new PatternBasedParser().Replace(reader.GetAssemblyFileVersion(), AssemblyFileVersionPattern); writer.ModifyAssemblyFileVersionTo(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); }