private async Task <bool> RemoveAppConfigFromProjectFile(string projectFile) { CSharpProjectFileUpdater csProjFile; using (var readFile = filesystem.OpenRead(projectFile, false)) { csProjFile = CSharpProjectFileUpdater.Create(readFile); csProjFile.RemoveAppConfig(); if (!csProjFile.HasChanges) { return(false); } csProjFile.RemoveEmptyItemGroups(); } using (var outputStream = new MemoryStream()) { csProjFile.Save(outputStream); outputStream.Position = 0; await filesystem.SaveContentAsync(projectFile, outputStream).ConfigureAwait(false); } return(true); }
public void RemoveAppConfig_RemovedAppConfigTest() { // arrange using (var inputStream = ResourceFile.OpenRead(Filename)) using (var outputStream = new MemoryStream()) { // act CSharpProjectFileUpdater.Create(inputStream) .RemoveAppConfig() .Save(outputStream); // assert Approvals.Verify(GetContent(outputStream)); } }
public void RemoveEmptyItemGroups_RemovesEmptyGroupsTest() { // arrange using (var inputStream = ResourceFile.OpenRead(Filename)) using (var outputStream = new MemoryStream()) { var sut = CSharpProjectFileUpdater.Create(inputStream) .RemoveAppConfig(); // act sut.RemoveEmptyItemGroups(); // assert sut.Save(outputStream); Approvals.Verify(GetContent(outputStream)); } }
public void UpdateCsProjFile_NonStableVersions_Ignored() { var updater = new CSharpProjectFileUpdater(); var file = new CsProjPackageVersion { File = XDocument.Parse(_sampleXml) }; var latestVersions = new List <IPackageInfo> { new PackageInfo { PackageId = "Newtonsoft.Json", Version = "12.0.3" }, new PackageInfo { PackageId = "Microsoft.TeamFoundationServer.Client", Version = "16.143.1" } }; var result = updater.UpdateCsProjFile(file, latestVersions); Assert.IsNotNull(result); }