public void PackageNameIsEmpty_Throws() { var manager = new NuGetManager(); var ex = Assert.Throws<ArgumentNullException>(() => manager.InstallPackage("DummyPath", null)); Assert.Contains("packageName", ex.Message); ex = Assert.Throws<ArgumentNullException>(() => manager.InstallPackage("DummyPath", string.Empty)); Assert.Contains("packageName", ex.Message); }
public void PhysicalPathIsEmpty_Throws() { var manager = new NuGetManager(); var ex = Assert.Throws<ArgumentNullException>(() => manager.InstallPackage(null, "DummyPackage")); Assert.Contains("appPhysicalPath", ex.Message); ex = Assert.Throws<ArgumentNullException>(() => manager.InstallPackage(string.Empty, "DummyPackage")); Assert.Contains("appPhysicalPath", ex.Message); }
public void SourcesProvided_NugetDefaultFeedIncluded() { // arrange var mockNugetCore = new Mock<INuGetCore>(); mockNugetCore.Setup(n => n.InstallPackage("DummyPath", "DummyPackage", It.Is<string>(s => s.Contains(NuGetManager.NUGET_DEFAULT_SOURCE)), "", null)) .Returns(() => null) .Verifiable(); var mockFileSystem = new Mock<Core.Abstractions.IFileSystem>(); // act var manager = new NuGetManager(mockNugetCore.Object, mockFileSystem.Object); manager.InstallPackage("DummyPath", "DummyPackage", "http://DummyFeed"); // assert mockNugetCore.Verify(); }
public void BinariesOnlyTrue_WebConfigDoesntExist() { // arrange var mockNugetCore = new Mock<INuGetCore>(); var mockFileSystem = new Mock<Core.Abstractions.IFileSystem>(MockBehavior.Strict); mockFileSystem.Setup(fs => fs.DirectorySetAttribute("DummyPath", FileAttributes.Normal)); mockFileSystem.Setup(fs => fs.FileExists(@"DummyPath\web.config")).Returns(false).Verifiable(); mockFileSystem.Setup(fs => fs.FileExists(@"DummyPath\web.config.temp")).Returns(false).Verifiable(); // act var manager = new NuGetManager(mockNugetCore.Object, mockFileSystem.Object); manager.InstallPackage(@"DummyPath", "DummyPackage", binariesOnly: true); // assert mockFileSystem.Verify(); // assert we don't call any other FileSystem APIs handled by MockBehavior.Strict }
public void BinariesOnlyTrue_WebConfigIsPreserved() { // arrange var mockNugetCore = new Mock<INuGetCore>(); var mockFileSystem = new Mock<Core.Abstractions.IFileSystem>(); mockFileSystem.Setup(fs => fs.DirectorySetAttribute("DummyPath", FileAttributes.Normal)); mockFileSystem.Setup(fs => fs.FileExists(@"DummyPath\web.config")).Returns(true).Verifiable(); mockFileSystem.Setup(fs => fs.FileCopy(@"DummyPath\web.config", @"DummyPath\web.config.temp", true)).Verifiable(); mockFileSystem.Setup(fs => fs.FileExists(@"DummyPath\web.config.temp")).Returns(true).Verifiable(); mockFileSystem.Setup(fs => fs.FileCopy(@"DummyPath\web.config.temp", @"DummyPath\web.config", true)).Verifiable(); mockFileSystem.Setup(fs => fs.FileDelete(@"DummyPath\web.config.temp")).Verifiable(); // act var manager = new NuGetManager(mockNugetCore.Object, mockFileSystem.Object); manager.InstallPackage(@"DummyPath", "DummyPackage", binariesOnly: true); // assert mockFileSystem.Verify(); }
public void BinariesOnlyFalse_WebConfigNotPreserved() { var mockNugetCore = new Mock<INuGetCore>(); var mockFileSystem = new Mock<Core.Abstractions.IFileSystem>(MockBehavior.Strict); mockFileSystem.Setup(fs => fs.DirectorySetAttribute("DummyPath", FileAttributes.Normal)); // act // assert we don't call any other FileSystem APIs handled by MockBehavior.Strict var manager = new NuGetManager(mockNugetCore.Object, mockFileSystem.Object); manager.InstallPackage(@"DummyPath", "DummyPackage", binariesOnly: false); }