Esempio n. 1
0
        public void UpdateSettings_UpdatesRecentProjectsBasedOnFlag(bool updating)
        {
            var settings   = AddRemoveReferencesSetup.GetNonDefaultReferenceSettings();
            var reconciler = AddRemoveReferencesSetup.ArrangeReferenceReconciler(settings);

            var input = settings.GetRecentReferencesForHost("EXCEL.EXE").Select(info =>
                                                                                new ReferenceModel(info, ReferenceKind.Project)
            {
                IsRecent = true
            }).ToList();

            var added  = DummyReferenceInfo;
            var output = input.Union(new[] { new ReferenceModel(added, ReferenceKind.TypeLibrary)
                                             {
                                                 IsReferenced = true
                                             } }).ToList();

            var model = AddRemoveReferencesSetup.ArrangeAddRemoveReferencesModel(output, null, settings);

            reconciler.UpdateSettings(model.Object, updating);

            var actual   = settings.GetRecentReferencesForHost("EXCEL.EXE");
            var expected = (updating ? output : input).Select(reference => reference.ToReferenceInfo()).ToList();

            Assert.AreEqual(updating ? expected.Count : input.Count, actual.Count);
            Assert.IsTrue(expected.All(info => actual.Contains(info)));
        }
Esempio n. 2
0
        public void UpdateSettings_UpdatesRecentLibrariesBasedOnFlag(bool updating)
        {
            var settings   = AddRemoveReferencesSetup.GetNonDefaultReferenceSettings();
            var reconciler = AddRemoveReferencesSetup.ArrangeReferenceReconciler(settings);

            var input = settings.GetRecentReferencesForHost(null).Select(info =>
                                                                         new ReferenceModel(info, ReferenceKind.TypeLibrary)
            {
                IsRecent = true
            }).ToList();

            var added  = new ReferenceInfo(AddRemoveReferencesSetup.DummyGuidOne, "Reference", @"C:\Windows\System32\reference.dll", 1, 0);
            var output = input.Union(new [] { new ReferenceModel(added, ReferenceKind.TypeLibrary)
                                              {
                                                  IsReferenced = true
                                              } }).ToList();

            var model = AddRemoveReferencesSetup.ArrangeAddRemoveReferencesModel(output, null, settings);

            reconciler.UpdateSettings(model.Object, updating);

            var actual   = settings.GetRecentReferencesForHost(null);
            var expected = (updating ? output : input).Select(reference => reference.ToReferenceInfo()).ToList();

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.IsTrue(expected.All(info => actual.Contains(info)));
        }
Esempio n. 3
0
        public void ViewModelFilters_SearchInputFiltersList(string input, int expected)
        {
            var declaration = AddRemoveReferencesSetup.ArrangeMocksAndGetProject();
            var settings    = AddRemoveReferencesSetup.GetNonDefaultReferenceSettings();
            var model       = new AddRemoveReferencesModel(null, declaration, SearchReferencesList, settings);
            var reconciler  = AddRemoveReferencesSetup.ArrangeReferenceReconciler(settings);

            var viewModel = new AddRemoveReferencesViewModel(model, reconciler, new Mock <IFileSystemBrowserFactory>().Object, null);

            viewModel.SelectedFilter = ReferenceFilter.ComTypes.ToString();
            viewModel.Search         = input;

            var actual = viewModel.AvailableReferences.OfType <ReferenceModel>().Count();

            Assert.AreEqual(expected, actual);
        }