FindPackage() public method

public FindPackage ( string packageId ) : IPackage
packageId string
return IPackage
コード例 #1
0
        public void FindPackage_PackageIdParameterIsNotValid_ArgumentExceptionIsThrown(string packageId)
        {
            // Arrange
            var sourceRepositoryProviderMock = new Mock<ISourceRepositoryProvider>();
            sourceRepositoryProviderMock.Setup(r => r.GetRepositoryConfigurations()).Returns(new List<SourceRepositoryConfiguration>());

            var packageRepositoryFactoryMock = new Mock<IPackageRepositoryFactory>();
            packageRepositoryFactoryMock.Setup(f => f.CreateRepository(It.IsAny<string>())).Returns(new Mock<IPackageRepository>().Object);

            var packageRepositoryBrowser = new PackageRepositoryBrowser(sourceRepositoryProviderMock.Object, packageRepositoryFactoryMock.Object);

            // Act
            packageRepositoryBrowser.FindPackage(packageId);
        }
コード例 #2
0
        public void FindPackage_PackageIdIsValid_NoRepositoriesAreConfigured_ResultIsNull()
        {
            // Arrange
            var sourceRepositoryProviderMock = new Mock<ISourceRepositoryProvider>();
            sourceRepositoryProviderMock.Setup(r => r.GetRepositoryConfigurations()).Returns(new List<SourceRepositoryConfiguration>());

            var packageRepositoryFactoryMock = new Mock<IPackageRepositoryFactory>();
            packageRepositoryFactoryMock.Setup(f => f.CreateRepository(It.IsAny<string>())).Returns(new Mock<IPackageRepository>().Object);

            var packageRepositoryBrowser = new PackageRepositoryBrowser(sourceRepositoryProviderMock.Object, packageRepositoryFactoryMock.Object);

            // Act
            IPackage result = packageRepositoryBrowser.FindPackage("package");

            // Assert
            Assert.IsNull(result);
        }