private void Initialize()
        {
            // Visuals
            this.Title = SD.ResourceService.GetString("AddInManager.Title");

            // Add event handlers
            AddInManager.Events.OperationStarted    += AddInManager_Events_OperationStarted;
            AddInManager.Events.AddInOperationError += AddInManager_Events_AddInOperationError;
            AddInManager.Events.AcceptLicenses      += AddInManager_Events_AcceptLicenses;

            _viewModels = new ObservableCollection <AddInsViewModelBase>();

            // Create and collect the models
            InstalledAddInsViewModel = new InstalledAddInsViewModel();
            AvailableAddInsViewModel = new AvailableAddInsViewModel();
            UpdatedAddInsViewModel   = new UpdatedAddInsViewModel();

            _viewModels.Add(InstalledAddInsViewModel);
            _viewModels.Add(AvailableAddInsViewModel);
            _viewModels.Add(UpdatedAddInsViewModel);

            foreach (var viewModel in _viewModels)
            {
                viewModel.PropertyChanged += ViewModel_PropertyChanged;
            }

            AddInManager.Events.OnAddInManagerViewOpened();

            // Expand the first view
            InstalledAddInsViewModel.IsExpandedInView = true;

            // Read the packages
            AvailableAddInsViewModel.ReadPackages();
            InstalledAddInsViewModel.ReadPackages();
            UpdatedAddInsViewModel.ReadPackages();
        }
		public void ShowInstalledOfflineAddIns()
		{
			CreateAddIns();
			_addIn1.Enabled = true;
			
			// Empty list of NuGet repositories
			_services.FakeRepositories.RegisteredPackageSources = new List<PackageSource>();
			_services.FakeRepositories.RegisteredPackageRepositories = new List<IPackageRepository>();
			FakeCorePackageRepository localRepository = new FakeCorePackageRepository();
			_services.FakeNuGet.FakeCorePackageManager.LocalRepository = localRepository;
			localRepository.ReturnedPackages = (new IPackage[] { }).AsQueryable();
			
			// Simulate list of AddIns
			_services.FakeSDAddInManagement.RegisteredAddIns.Add(_addIn1);
			_services.FakeSDAddInManagement.RegisteredAddIns.Add(_addIn2);
			
			var viewModel = new InstalledAddInsViewModel(_services);
			viewModel.ReadPackagesAndWaitForUpdate();
			
			Assert.That(viewModel.AddInPackages.Count, Is.EqualTo(2), "AddIn list must contain 2 items.");
			
			AddInPackageViewModelBase firstAddIn = viewModel.AddInPackages[0];
			Assert.That(firstAddIn.Id, Is.EqualTo(_addIn1.Manifest.PrimaryIdentity), "Primary identity of 1st AddIn");
			Assert.That(firstAddIn.Name, Is.EqualTo(_addIn1.Name), "Name of 1st AddIn");
			Assert.That(firstAddIn.Version, Is.EqualTo(_addIn1.Version), "Version of 1st AddIn");
			Assert.That(firstAddIn.IsInstalled, Is.True, "1st AddIn must be 'installed''");
			Assert.That(firstAddIn.IsOffline, Is.True, "1st AddIn must be 'offline'");
			Assert.That(firstAddIn.IsEnabled, Is.True, "1st AddIn must be 'enabled'");
			Assert.That(firstAddIn.IsUpdate, Is.False, "1st AddIn must not be 'update'");
			Assert.That(firstAddIn.IsAdded, Is.False, "1st AddIn must not be 'added'");
			Assert.That(firstAddIn.IsRemoved, Is.False, "1st AddIn must not be 'removed'");
			Assert.That(firstAddIn.HasNuGetConnection, Is.False, "1st AddIn must not have 'NuGet connection'");
			
			// Check 'externally referenced' status of both AddIns
			// (simulating that IsAddInManifestIinExternalPath() returns true for 1st AddIn and false for 2nd)
			_services.FakeSDAddInManagement.IsAddInManifestInExternalPathCallback = (addIn) => addIn == _addIn1;
			Assert.That(viewModel.AddInPackages[0].IsExternallyReferenced, Is.True, "1st AddIn must be 'externally referenced'");
			Assert.That(viewModel.AddInPackages[1].IsExternallyReferenced, Is.False, "2nd AddIn must not be 'externally referenced'");
		}
		public void ShowNuGetAddInMarkedForUninstallation()
		{
			CreateAddIns();
			_addIn1.Enabled = true;
			_addIn1.Action = AddInAction.Uninstall;
			
			// Create a fake package
			FakePackage fakePackage = new FakePackage()
			{
				Id = _addIn1.Manifest.PrimaryIdentity,
				Version = new SemanticVersion(_addIn1.Version),
				Tags = SharpDevelopAddInTag
			};
			_addIn1.Properties.Set(ManagedAddIn.NuGetPackageIDManifestAttribute, fakePackage.Id);
			_addIn1.Properties.Set(ManagedAddIn.NuGetPackageVersionManifestAttribute, fakePackage.Version.ToString());
			
			// Empty list of NuGet repositories
			_services.FakeRepositories.RegisteredPackageSources = new List<PackageSource>();
			_services.FakeRepositories.RegisteredPackageRepositories = new List<IPackageRepository>();
			FakeCorePackageRepository localRepository = new FakeCorePackageRepository();
			_services.FakeNuGet.FakeCorePackageManager.LocalRepository = localRepository;
			localRepository.ReturnedPackages = (new IPackage[] { fakePackage }).AsQueryable();
			
			// Simulate list of AddIns
			_services.FakeSDAddInManagement.RegisteredAddIns.Add(_addIn1);
			_services.FakeSDAddInManagement.RegisteredAddIns.Add(_addIn2);
			
			var viewModel = new InstalledAddInsViewModel(_services);
			viewModel.ReadPackagesAndWaitForUpdate();
			
			Assert.That(viewModel.AddInPackages.Count, Is.EqualTo(2), "AddIn list must contain 2 items.");
			
			AddInPackageViewModelBase firstAddIn = viewModel.AddInPackages[0];
			Assert.That(firstAddIn.Id, Is.EqualTo(_addIn1.Manifest.PrimaryIdentity), "Primary identity of 1st AddIn");
			Assert.That(firstAddIn.Name, Is.EqualTo(_addIn1.Name), "Name of 1st AddIn");
			Assert.That(firstAddIn.Version, Is.EqualTo(_addIn1.Version), "Version of 1st AddIn must be the one of the update");
			Assert.That(firstAddIn.IsInstalled, Is.True, "1st AddIn must be 'installed''");
			Assert.That(firstAddIn.IsOffline, Is.True, "1st AddIn must be 'offline'");
			Assert.That(firstAddIn.IsEnabled, Is.True, "1st AddIn must be 'enabled'");
			Assert.That(firstAddIn.IsUpdate, Is.False, "1st AddIn must not be 'update'");
			Assert.That(firstAddIn.IsAdded, Is.False, "1st AddIn must not be 'added'");;
			Assert.That(firstAddIn.IsRemoved, Is.True, "1st AddIn must be 'removed'");
			Assert.That(firstAddIn.HasNuGetConnection, Is.True, "1st AddIn must have 'NuGet connection'");
		}