public void RemovingPackageDoesNotRemoveImportFileIfFilePatternDoesNotMatch() { // Arrange var sourceRepository = new MockPackageRepository(); var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework, Version=4.5"), "x:\\root"); projectSystem.AddImport(@"x:\root\A.1.0\content\net35\A.props", ProjectImportLocation.Top); projectSystem.AddImport(@"x:\root\A.1.0\content\net35\A.targets", ProjectImportLocation.Bottom); var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository()); IPackage packageA = PackageUtility.CreatePackage( "A", "1.0", content: new[] { "net35\\A.1.0.props", "net35\\B.targets" }); projectManager.LocalRepository.AddPackage(packageA); sourceRepository.AddPackage(packageA); // Act projectManager.RemovePackageReference("A"); // Assert Assert.False(projectManager.LocalRepository.Exists(packageA)); Assert.True(projectSystem.ImportExists(@"x:\root\A.1.0\content\net35\A.props")); Assert.True(projectSystem.ImportExists(@"x:\root\A.1.0\content\net35\A.targets")); }
public void AddPackageReferenceDoesNotImportsTargetOrPropFileThatAreNotAtContentRoot() { // Arrange var projectSystem = new MockProjectSystem(new FrameworkName("Native", new Version("2.0")), "x:\\root"); var localRepository = new MockPackageRepository(); var mockRepository = new MockPackageRepository(); var projectManager = new ProjectManager(mockRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository); var packageA = PackageUtility.CreatePackage("A", "1.0"); var mockPackageA = Mock.Get(packageA); var files = PackageUtility.CreateFiles(new[] { "build\\native\\foo\\A.targets", "build\\native\\bar\\B.props", "content\\native\\foo.css" }); mockPackageA.Setup(p => p.GetFiles()).Returns(files); mockRepository.AddPackage(mockPackageA.Object); // Act projectManager.AddPackageReference("A"); // Assert Assert.True(localRepository.Exists("A")); Assert.False(projectSystem.ImportExists("x:\\root\\A.1.0\\build\\native\\foo\\A.targets")); Assert.False(projectSystem.ImportExists("x:\\root\\A.1.0\\build\\native\\bar\\A.props")); }
public void RemovingPackageRemoveImportFile() { // Arrange var sourceRepository = new MockPackageRepository(); var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework, Version=4.5"), "x:\\root"); projectSystem.AddImport(@"x:\root\A.1.0\build\net35\A.props", ProjectImportLocation.Top); projectSystem.AddImport(@"x:\root\A.1.0\build\net35\A.targets", ProjectImportLocation.Bottom); var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository()); IPackage packageA = PackageUtility.CreatePackage("A", "1.0"); var mockPackageA = Mock.Get(packageA); var files = PackageUtility.CreateFiles(new[] { "build\\net35\\A.targets", "build\\net35\\a.props" }); mockPackageA.Setup(p => p.GetFiles()).Returns(files); projectManager.LocalRepository.AddPackage(packageA); sourceRepository.AddPackage(packageA); // Act projectManager.RemovePackageReference("A"); // Assert Assert.False(projectManager.LocalRepository.Exists(packageA)); Assert.False(projectSystem.ImportExists(@"x:\root\A.1.0\content\net35\A.props")); Assert.False(projectSystem.ImportExists(@"x:\root\A.1.0\content\net35\A.targets")); }