/// <summary> /// Adds files to csproj /// </summary> /// <returns>The result of the operation</returns> protected FileModifierResult AddFilesToCsProj() { string csprojFilePath = GetCsprojFilePath(); FileModifierResult result = CsProjModifier.AddFiles(csprojFilePath, this.createdFiles); return(result); }
public void SuccessfullyAddNewContentFile_When_CsProjDoesNotHaveOtherContentElements() { FileModifierResult result = CsProjModifier.AddFiles(CsProjWithoutElementsPath, new List <string> { JavascriptDummyFile }); Assert.IsTrue(result.Success); XDocument resultCsproj = XDocument.Load(CsProjWithoutElementsPath); XElement contentElem = resultCsproj.Descendants().FirstOrDefault(x => x.Name.ToString().EndsWith(Constants.ContentElem)); Assert.IsNotNull(contentElem); Assert.AreEqual(JavascriptDummyFile, contentElem.Attribute(Constants.IncludeAttribute).Value); }
public void NotAddContentFileTwice_When_CsProjAlreadyHasTheSameContentElement() { IEnumerable <XElement> contentElementsBeforeAdd = _initialCsprojWithElements.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)); string firstContentElementIncludeValue = contentElementsBeforeAdd.First().Attribute(Constants.IncludeAttribute).Value; CsProjModifier.AddFiles(CsProjWithElementsPath, new List <string> { firstContentElementIncludeValue }); XDocument resultCsproj = XDocument.Load(CsProjWithElementsPath); IEnumerable <XElement> contentElementsAfterAdd = resultCsproj.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)); int contentElementsBeforeAddCount = contentElementsBeforeAdd.Count(); int contentElementsAfterAddCount = contentElementsAfterAdd.Count(); Assert.AreEqual(contentElementsAfterAddCount, contentElementsBeforeAddCount); }
public void SuccessfullyAddNewContentFile_When_CsProjHasOtherContentElements() { FileModifierResult result = CsProjModifier.AddFiles(CsProjWithElementsPath, new List <string> { JavascriptDummyFile }); Assert.IsTrue(result.Success); XDocument resultCsproj = XDocument.Load(CsProjWithElementsPath); IEnumerable <XElement> contentElementsAfterAdd = resultCsproj.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)); int contentElementsBeforeAddCount = _initialCsprojWithElements.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)).Count(); int contentElementsAfterAddCount = contentElementsAfterAdd.Count(); Assert.AreNotEqual(contentElementsBeforeAddCount, contentElementsAfterAddCount); XElement newContentElem = contentElementsAfterAdd.Last(); Assert.AreEqual(JavascriptDummyFile, newContentElem.Attribute(Constants.IncludeAttribute).Value); }