/// <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 Fail_When_IncorrectWebAppName() { FileModifierResult result = SlnModifier.AddFile(this.slnFilePathWithoutElements, this.csProjFilePath, this.projectGuid, this.incorrectWebAppName); Assert.IsFalse(result.Success); Assert.AreEqual("Unable to read solution", result.Message); }
public void Fail_When_SolutionPathIsIncorrect() { FileModifierResult result = SlnModifier.AddFile(this.incorrectSlnFilePath, this.csProjFilePath, this.projectGuid, this.correctWebAppName); Assert.IsFalse(result.Success); Assert.AreEqual($"Unable to find {this.incorrectSlnFilePath}", result.Message); }
public void SuccessfullyRegisterNewExtension_When_IndexFileHasNoRegisteredModules() { FileModifierResult result = TsModuleModifier.RegisterExtension(this.IndexWithoutModulesPath, "TestModule", "test"); Assert.IsTrue(result.Success); var currentState = File.ReadAllText(this.IndexWithoutModulesPath); Assert.AreEqual(this._expectedIndexWithoutModules, currentState); }
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 SuccessfullyAddNewProject_When_AllIsCorrect() { FileModifierResult result = SlnModifier.AddFile(this.slnFilePathWithElements, this.csProjFilePath, this.projectGuid, this.correctWebAppName); Assert.IsTrue(result.Success); var slnContents = File.ReadAllText(this.slnFilePathWithElements); Assert.IsFalse(string.IsNullOrEmpty(slnContents)); var csProjRelativeFilePath = Path.GetRelativePath(Path.GetDirectoryName(this.slnFilePathWithElements), this.csProjFilePath); Assert.IsTrue(slnContents.Contains(csProjRelativeFilePath)); }
public void SuccessfullyRemoveContentFile_When_CsProjHasOtherContentElements() { IEnumerable <XElement> contentElementsBeforeRemove = _initialCsprojWithElements.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)); string firstContentElementIncludeValue = contentElementsBeforeRemove.First().Attribute(Constants.IncludeAttribute).Value; FileModifierResult result = CsProjModifier.RemoveFiles(CsProjWithElementsPath, new List <string> { firstContentElementIncludeValue }); Assert.IsTrue(result.Success); XDocument resultCsproj = XDocument.Load(CsProjWithElementsPath); IEnumerable <XElement> contentElementsAfterRemove = resultCsproj.Descendants().Where(x => x.Name.ToString().EndsWith(Constants.ContentElem)); int contentElementsBeforeRemoveCount = contentElementsBeforeRemove.Count(); int contentElementsAfterRemoveCount = contentElementsAfterRemove.Count(); Assert.AreNotEqual(contentElementsAfterRemoveCount, contentElementsBeforeRemoveCount); }
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); }