Example #1
0
        public static void GetLocalRepositoryWhenSolutionDirectoryIsNotFound()
        {
            // Arrange
            var mockRepositoryFactory   = new Mock <IPackageRepositoryFactory>();
            var mockSourceProvider      = new Mock <IVsPackageSourceProvider>();
            var mockAggregateRepository = new Mock <AggregateRepository>(Enumerable.Empty <IPackageRepository>());
            var solutionManager         = new Mock <ISolutionManager>();

            solutionManager.Setup(s => s.SolutionDirectory).Returns(String.Empty);
            var fileSystemProvider    = new Mock <IFileSystemProvider>();
            var repositorySettings    = new RepositorySettings(solutionManager.Object, fileSystemProvider.Object, new Mock <IVsSourceControlTracker>().Object, null);
            var packageManagerFactory = new VsPackageManagerFactory(
                new Mock <ISolutionManager>().Object,
                mockRepositoryFactory.Object,
                mockSourceProvider.Object,
                new Mock <IFileSystemProvider>().Object,
                repositorySettings,
                new Mock <VsPackageInstallerEvents>().Object,
                mockAggregateRepository.Object,
                frameworkMultiTargeting: null,
                machineWideSettings: null);

            // Act & Assert
            // Get RepositoryPath throws InvalidOperationException and GetLocalRepository() handles it to return null
            // To make a delegate out of property repositorySettings.RepositoryPath, calling String.IsNullOrEmpty
            ExceptionAssert.Throws <InvalidOperationException>(() => String.IsNullOrEmpty(repositorySettings.RepositoryPath), "Unable to locate the solution directory. Please ensure that the solution has been saved.");
            Assert.Null(ProjectRetargetingUtility.GetLocalRepository(packageManagerFactory));
        }
        public static void GetLocalRepositoryWhenCreatePackageManagerReturnsNull()
        {
            // Arrange
            var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
            packageManagerFactory.Setup(p => p.CreatePackageManager()).Returns((IVsPackageManager)null);

            // Act
            var localRepository = ProjectRetargetingUtility.GetLocalRepository(packageManagerFactory.Object);

            // Assert
            Assert.Null(localRepository);
        }
Example #3
0
 public static void GetLocalRepositoryWhenPackageManagerFactoryIsNull()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNull(() => ProjectRetargetingUtility.GetLocalRepository(null), "packageManagerFactory");
 }