本文整理汇总了C#中PackageReferenceRepository.RemovePackage方法的典型用法代码示例。如果您正苦于以下问题:C# PackageReferenceRepository.RemovePackage方法的具体用法?C# PackageReferenceRepository.RemovePackage怎么用?C# PackageReferenceRepository.RemovePackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageReferenceRepository
的用法示例。
在下文中一共展示了PackageReferenceRepository.RemovePackage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemovePackageRemovesEntryFromPackagesConfigDeletesFileAndUnregistersRepositoryIfLastEntry
public void RemovePackageRemovesEntryFromPackagesConfigDeletesFileAndUnregistersRepositoryIfLastEntry()
{
// Arrange
var sharedRepository = new Mock<ISharedPackageRepository>();
string path = null;
sharedRepository.Setup(m => m.UnregisterRepository(It.IsAny<string>()))
.Callback<string>(p => path = p);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, sharedRepository.Object);
var package = PackageUtility.CreatePackage("A");
// Act
referenceRepository.RemovePackage(package);
// Assert
Assert.False(fileSystem.FileExists("packages.config"));
Assert.NotNull(path);
Assert.Equal(@"C:\MockFileSystem\packages.config", path);
}
示例2: RemovePackageRemovesEntryFromPackagesConfig
public void RemovePackageRemovesEntryFromPackagesConfig()
{
// Arrange
var sharedRepository = new Mock<ISharedPackageRepository>();
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
<package id=""B"" version=""1.0"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, sharedRepository.Object);
var package = PackageUtility.CreatePackage("A");
// Act
referenceRepository.RemovePackage(package);
// Assert
Assert.True(fileSystem.FileExists("packages.config"));
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""B"" version=""1.0"" />
</packages>", fileSystem.ReadAllText("packages.config"));
}
示例3: RemovePackagePreservesProjectConfigFile
public void RemovePackagePreservesProjectConfigFile()
{
// Arrange
var repository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
var packageA = PackageUtility.CreatePackage("A");
repository.Object.AddPackage(packageA);
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.cool.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
<package id=""B"" version=""3.0"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, projectName: "cool", sourceRepository: repository.Object);
var packageB = PackageUtility.CreatePackage("B", "3.0");
// Act
referenceRepository.RemovePackage(packageB);
// Assert
Assert.False(fileSystem.FileExists("packages.config"));
Assert.True(fileSystem.FileExists("packages.cool.config"));
string content = fileSystem.ReadAllText("packages.cool.config");
AssertConfig(@"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" />
</packages>", content);
}
示例4: RemovingAndAddingPackageReferenceWithSameIdPreservesConstraint
public void RemovingAndAddingPackageReferenceWithSameIdPreservesConstraint()
{
// Arrange
var sharedRepository = new Mock<ISharedPackageRepository>();
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" allowedVersions=""[1.0, 5.0)"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, sharedRepository.Object);
var A10 = PackageUtility.CreatePackage("A");
var A20 = PackageUtility.CreatePackage("A", "2.0");
// Act
referenceRepository.RemovePackage(A10);
referenceRepository.AddPackage(A20);
// Assert
Assert.True(fileSystem.FileExists("packages.config"));
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""2.0"" allowedVersions=""[1.0, 5.0)"" />
</packages>", fileSystem.ReadAllText("packages.config"));
}
示例5: RemovingAndAddingPackageReferenceWithSameIdPreservesDevelopmentFlag
public void RemovingAndAddingPackageReferenceWithSameIdPreservesDevelopmentFlag()
{
// Arrange
var sharedRepository = new Mock<ISharedPackageRepository>();
var fileSystem = new MockFileSystem();
fileSystem.AddFile("packages.config", @"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""1.0"" developmentDependency=""false"" />
</packages>");
var referenceRepository = new PackageReferenceRepository(fileSystem, projectName: null, sourceRepository: sharedRepository.Object);
var A10 = PackageUtility.CreatePackage("A");
var A20 = PackageUtility.CreatePackage("A", "2.0");
// Act
referenceRepository.RemovePackage(A10);
referenceRepository.AddPackage(A20);
// Assert
Assert.True(fileSystem.FileExists("packages.config"));
AssertConfig(@"<?xml version=""1.0"" encoding=""utf-8""?>
<packages>
<package id=""A"" version=""2.0"" developmentDependency=""false"" />
</packages>", fileSystem.ReadAllText("packages.config"));
}