public void UpdateProjectXmlVersionElementWithStandardXmlModifiesElement(string xml) { var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); ProjectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer !); var expectedXml = XElement.Parse(@" <Project Sdk=""Microsoft.NET.Sdk""> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> <AssemblyVersion>2.0.0.0</AssemblyVersion> </PropertyGroup> </Project>"); xmlRoot.ToString().ShouldBe(expectedXml.ToString()); }
public void UpdateProjectXmlVersionElementWithMultipleVersionElementsLastOneIsModified(string xml) { using var projectFileUpdater = new ProjectFileUpdater(log, fileSystem); var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); projectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer); var expectedXml = XElement.Parse(@" <Project Sdk=""Microsoft.NET.Sdk""> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> <AssemblyVersion>1.0.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </PropertyGroup> </Project>"); xmlRoot.ToString().ShouldBe(expectedXml.ToString()); }