예제 #1
0
		private void PrepareAddInSetup()
		{
			_events = new AddInManagerEvents();
			_nuGet = new FakeNuGetPackageManager();
			_sdAddInManagement = new FakeSDAddInManagement();
			_addInSetup = new AddInSetup(_events, _nuGet, _sdAddInManagement);
		}
		public void ReadRepositoriesFromConfiguration()
		{
			FakeAddInManagerSettings settings = new FakeAddInManagerSettings();
			settings.PackageRepositories = new string[]
			{
				@"Repository1=C:\Repositories\Repository1",
				@"Repository2=C:\Repositories\Repository2"
			};
			
			AddInManagerEvents events = new AddInManagerEvents();
			PackageRepositories packageRepositories = new PackageRepositories(events, settings);
			
			var packageSources = packageRepositories.RegisteredPackageSources;
			Assert.That(packageSources, Is.Not.Null);
			Assert.That(packageSources.Count(), Is.EqualTo(3));
			
			// Default repository also must be present in first place
			Assert.That(packageSources.ElementAt(0).Name, Is.EqualTo(PackageRepositories.DefaultRepositoryName));
			Assert.That(packageSources.ElementAt(0).Source, Is.EqualTo(PackageRepositories.DefaultRepositorySource));
			
			// Then others are following
			Assert.That(packageSources.ElementAt(1).Name, Is.EqualTo("Repository1"));
			Assert.That(packageSources.ElementAt(1).Source, Is.EqualTo(@"C:\Repositories\Repository1"));
			Assert.That(packageSources.ElementAt(2).Name, Is.EqualTo("Repository2"));
			Assert.That(packageSources.ElementAt(2).Source, Is.EqualTo(@"C:\Repositories\Repository2"));
		}
		public void ReadInvalidRepositoriesFromConfiguration()
		{
			FakeAddInManagerSettings settings = new FakeAddInManagerSettings();
			settings.PackageRepositories = new string[]
			{
				@"Repository1|C:\Repositories\Repository1",
				"=",
				""
			};
			
			AddInManagerEvents events = new AddInManagerEvents();
			PackageRepositories packageRepositories = new PackageRepositories(events, settings);
			
			var packageSources = packageRepositories.RegisteredPackageSources;
			Assert.That(packageSources, Is.Not.Null);
			
			// Must be 1, because DefaultRepository is always there...
			Assert.That(packageSources.Count(), Is.EqualTo(1));
		}
		public void ReadRepositoriesWithDefaultFromConfiguration()
		{
			FakeAddInManagerSettings settings = new FakeAddInManagerSettings();
			settings.PackageRepositories = new string[]
			{
				@"Repository1=C:\Repositories\Repository1",
				@"Repository2=C:\Repositories\Repository2",
				PackageRepositories.DefaultRepositoryName + "=" + PackageRepositories.DefaultRepositorySource
			};
			
			AddInManagerEvents events = new AddInManagerEvents();
			PackageRepositories packageRepositories = new PackageRepositories(events, settings);
			
			var packageSources = packageRepositories.RegisteredPackageSources;
			Assert.That(packageSources, Is.Not.Null);
			Assert.That(packageSources.Count(), Is.EqualTo(3));
			
			Assert.That(packageSources.ElementAt(0).Name, Is.EqualTo("Repository1"));
			Assert.That(packageSources.ElementAt(0).Source, Is.EqualTo(@"C:\Repositories\Repository1"));
			Assert.That(packageSources.ElementAt(1).Name, Is.EqualTo("Repository2"));
			Assert.That(packageSources.ElementAt(1).Source, Is.EqualTo(@"C:\Repositories\Repository2"));
			Assert.That(packageSources.ElementAt(2).Name, Is.EqualTo(PackageRepositories.DefaultRepositoryName));
			Assert.That(packageSources.ElementAt(2).Source, Is.EqualTo(PackageRepositories.DefaultRepositorySource));
		}
		public void SetUp()
		{
			_events = new AddInManagerEvents();
			_packageRepositories = new FakePackageRepositories();
			_sdAddInManagement = new FakeSDAddInManagement();
		}
		public void SaveRepositoriesToConfiguration()
		{
			FakeAddInManagerSettings settings = new FakeAddInManagerSettings();
			settings.PackageRepositories = new string[]
			{
				@"Repository1=C:\Repositories\Repository1",
				@"Repository2=C:\Repositories\Repository2"
			};
			
			AddInManagerEvents events = new AddInManagerEvents();
			PackageRepositories packageRepositories = new PackageRepositories(events, settings);
			
			List<PackageSource> packageSources = new List<PackageSource>();
			packageSources.Add(new PackageSource(@"C:\Repositories\Repository3", "Repository3"));
			packageSources.Add(new PackageSource(@"C:\Repositories\Repository4", "Repository4"));
			packageRepositories.RegisteredPackageSources = packageSources;
			
			var packageRepositoriesSetting = settings.PackageRepositories;
			Assert.That(packageRepositoriesSetting, Is.Not.Null);
			Assert.That(packageRepositoriesSetting.Count(), Is.EqualTo(3));
			
			// Default repository also must be there in first place
			Assert.That(packageRepositoriesSetting.ElementAt(0),
			            Is.EqualTo(PackageRepositories.DefaultRepositoryName + "=" + PackageRepositories.DefaultRepositorySource));
			
			// Then others are following
			Assert.That(packageRepositoriesSetting.ElementAt(1), Is.EqualTo(@"Repository3=C:\Repositories\Repository3"));
			Assert.That(packageRepositoriesSetting.ElementAt(2), Is.EqualTo(@"Repository4=C:\Repositories\Repository4"));
		}
		public void SaveInvalidRepositoryListToConfiguration()
		{
			FakeAddInManagerSettings settings = new FakeAddInManagerSettings();
			settings.PackageRepositories = new string[]
			{
				@"Repository1=C:\Repositories\Repository1",
				@"Repository2=C:\Repositories\Repository2"
			};
			
			AddInManagerEvents events = new AddInManagerEvents();
			PackageRepositories packageRepositories = new PackageRepositories(events, settings);

			// Setting invalid package source collection (null)			
			packageRepositories.RegisteredPackageSources = null;
			
			var packageRepositoriesSetting = settings.PackageRepositories;
			Assert.That(packageRepositoriesSetting, Is.Not.Null);
			// Must be 1, because DefaultRepository is always there...
			Assert.That(packageRepositoriesSetting.Count(), Is.EqualTo(1));
		}