コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }