void AddReferenceToProject(string name, string hintPath = null) { if (hintPath != null) { hintPath = hintPath.ToNativePath(); } ProjectHelper.AddReference(project, name, hintPath); }
public void ReferenceExists_ProjectReferenceNameHasDifferentCase_ReturnsTrue() { CreateTestProject(); ProjectHelper.AddReference(project, "myassembly"); CreateProjectSystem(project); string fileName = @"D:\Projects\Test\MYASSEMBLY.dll"; bool result = projectSystem.ReferenceExists(fileName); Assert.IsTrue(result); }
public void ReferenceExists_ProjectHasReferenceAndFullPathToAssemblyPassedToMethod_ReturnsTrue() { CreateTestProject(); ProjectHelper.AddReference(project, "MyAssembly"); CreateProjectSystem(project); string fileName = @"D:\Projects\Test\MyAssembly.dll"; bool result = projectSystem.ReferenceExists(fileName); Assert.IsTrue(result); }
public void ReferenceExists_ReferenceIsInProjectAndProjectReferenceSearchedForHasExeFileExtensionInUpperCase_ReturnsTrue() { CreateTestProject(@"D:\Projects\Test\MyProject.csproj"); ProjectHelper.AddReference(project, "myassembly", @"d:\Projects\Test\myassembly.exe".ToNativePath()); CreateProjectSystem(project); string fileName = @"D:\Projects\Test\MYASSEMBLY.EXE".ToNativePath(); bool result = projectSystem.ReferenceExists(fileName); Assert.IsTrue(result); }
public void ReferenceExists_ReferenceIsInProjectAndProjectReferenceSearchedForHasExeFileExtension_ReturnsTrue() { CreateTestProject(); ProjectHelper.AddReference(project, "myassembly"); CreateProjectSystem(project); string fileName = @"D:\Projects\Test\myassembly.exe"; bool result = projectSystem.ReferenceExists(fileName); Assert.IsTrue(result); }
public void ReferenceExists_ReferenceNamePassedIsInProjectAndIsReferenceNameWithNoFileExtension_ReturnsTrue() { CreateTestProject(); ProjectHelper.AddReference(project, "System.ComponentModel.Composition"); CreateProjectSystem(project); string referenceName = "System.ComponentModel.Composition"; bool result = projectSystem.ReferenceExists(referenceName); Assert.IsTrue(result); }
public void RemoveReference_ReferenceExistsInProject_ProjectIsSavedAfterReferenceRemoved() { CreateTestProject(); ProjectHelper.AddReference(project, "nunit.framework"); CreateProjectSystem(project); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll"; projectSystem.RemoveReference(fileName); Assert.AreEqual(0, project.ItemsWhenSaved.Count); }
public void RemoveReference_ReferenceExistsInProject_ProjectIsSavedAfterReferenceRemoved() { CreateTestProject(@"d:\projects\MyProject\MyProject.csproj"); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath(); ProjectHelper.AddReference(project, fileName); CreateProjectSystem(project); projectSystem.RemoveReference(fileName); Assert.AreEqual(0, project.ReferencesWhenSavedCount); }
public void ReferenceExists_ReferenceIsInProjectButIncludesAssemblyVersion_ReturnsTrue() { CreateTestProject(); string include = "MyAssembly, Version=0.1.0.0, Culture=neutral, PublicKeyToken=8cc8392e8503e009"; ProjectHelper.AddReference(project, include); CreateProjectSystem(project); string fileName = @"D:\Projects\Test\myassembly.dll"; bool result = projectSystem.ReferenceExists(fileName); Assert.IsTrue(result); }
public void RemoveReference_ReferenceCaseAddedToProjectDifferentToReferenceNameBeingRemoved_ReferenceRemovedFromProject() { CreateTestProject(); ProjectHelper.AddReference(project, "nunit.framework"); CreateProjectSystem(project); string fileName = @"NUNIT.FRAMEWORK.DLL"; projectSystem.RemoveReference(fileName); ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework"); Assert.IsNull(referenceItem); }
public void RemoveReference_ReferenceBeingRemovedHasFileExtension_ReferenceRemovedFromProject() { CreateTestProject(); ProjectHelper.AddReference(project, "nunit.framework"); CreateProjectSystem(project); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll"; projectSystem.RemoveReference(fileName); ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework"); Assert.IsNull(referenceItem); }
public void RemoveReference_ReferenceCaseAddedToProjectDifferentToReferenceNameBeingRemoved_ReferenceRemovedFromProject() { CreateTestProject(@"d:\projects\MyProject\MyProject.csproj"); ProjectHelper.AddReference(project, @"d:\projects\MyProject\packages\nunit\nunit.framework.dll".ToNativePath()); CreateProjectSystem(project); string fileName = @"NUNIT.FRAMEWORK.DLL"; projectSystem.RemoveReference(fileName); ProjectReference referenceItem = ProjectHelper.GetReference(project, "nunit.framework"); Assert.IsNull(referenceItem); }
public void RemoveReference_ReferenceBeingRemovedHasFileExtensionAndProjectHasReferenceIncludingAssemblyVersion_ReferenceRemovedFromProject() { CreateTestProject(); string include = "nunit.framework, Version=2.6.2.0, Culture=neutral, PublicKeyToken=8cc8392e8503e009"; ProjectHelper.AddReference(project, include); CreateProjectSystem(project); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll"; projectSystem.RemoveReference(fileName); ReferenceProjectItem referenceItem = ProjectHelper.GetReference(project, "nunit.framework"); Assert.IsNull(referenceItem); }
public void RemoveReference_ReferenceBeingRemovedHasFileExtension_ReferenceRemovalIsLogged() { CreateTestProject(); project.Name = "MyTestProject"; ProjectHelper.AddReference(project, "nunit.framework"); CreateProjectSystem(project); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll"; projectSystem.RemoveReference(fileName); var expectedReferenceAndProjectName = new ReferenceAndProjectName { Reference = "nunit.framework", Project = "MyTestProject" }; Assert.AreEqual(expectedReferenceAndProjectName, projectSystem.ReferenceAndProjectNamePassedToLogRemovedReferenceFromProject); }
public void RemoveReference_RemoveReferenceToNUnitFramework_ReferenceRemovingEventIsFired() { CreateTestProject(); CreateProjectSystem(project); string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath(); ProjectHelper.AddReference(project, fileName); ProjectReference referenceBeingRemoved = null; bool projectIsSaved = false; projectSystem.PackageManagementEvents.ReferenceRemoving += (sender, e) => { referenceBeingRemoved = e.Reference; projectIsSaved = project.IsSaved; }; projectSystem.RemoveReference(fileName); Assert.AreEqual(fileName, referenceBeingRemoved.HintPath); Assert.IsFalse(projectIsSaved); }