public void TestInitialize() { ThreadHelper.SetCurrentThreadAsUIThread(); mockTextView = Mock.Of <ITextView>(); var mockSnapshot = new Mock <ITextSnapshot>(); mockSnapshot.Setup(x => x.Length).Returns(100); mockSnapshotSpan = new SnapshotSpan(mockSnapshot.Object, 1, 10); outliningManagerServiceMock = new Mock <IOutliningManagerService>(); editorOperationsMock = new Mock <IEditorOperations>(); var editorOperationsFactoryMock = new Mock <IEditorOperationsFactoryService>(); editorOperationsFactoryMock .Setup(x => x.GetEditorOperations(mockTextView)) .Returns(editorOperationsMock.Object); testSubject = new DocumentNavigator(Mock.Of <IServiceProvider>(), Mock.Of <IVsEditorAdaptersFactoryService>(), outliningManagerServiceMock.Object, editorOperationsFactoryMock.Object); }
public QueryModel() { ModelUrl = "/query"; ApplicationModel.Current.Server.Value.RawUrl = null; queryDocument = new EditorDocument() { Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef") }; ExceptionLine = -1; ExceptionColumn = -1; CollectionSource = new QueryDocumentsCollectionSource(); Observable.FromEventPattern <QueryStatisticsUpdatedEventArgs>(h => CollectionSource.QueryStatisticsUpdated += h, h => CollectionSource.QueryStatisticsUpdated -= h) .SampleResponsive(TimeSpan.FromSeconds(0.5)) .TakeUntil(Unloaded) .ObserveOnDispatcher() .Subscribe(e => { QueryTime = e.EventArgs.QueryTime; Results = e.EventArgs.Statistics; }); Observable.FromEventPattern <QueryErrorEventArgs>(h => CollectionSource.QueryError += h, h => CollectionSource.QueryError -= h) .ObserveOnDispatcher() .Subscribe(e => HandleQueryError(e.EventArgs.Exception)); DocumentsResult = new DocumentsModel(CollectionSource) { Header = "Results", DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, IndexName, CollectionSource.TemplateQuery), }; QueryErrorMessage = new Observable <string>(); IsErrorVisible = new Observable <bool>(); SortBy = new BindableCollection <StringRef>(x => x.Value); SortBy.CollectionChanged += HandleSortByChanged; SortByOptions = new BindableCollection <string>(x => x); Suggestions = new BindableCollection <FieldAndTerm>(x => x.Field); DynamicOptions = new BindableCollection <string>(x => x) { "AllDocs" }; }
public CollectionsModel() { ModelUrl = "/collections"; ApplicationModel.Current.Server.Value.RawUrl = null; Collections = new BindableCollection <CollectionModel>(model => model.Name); SelectedCollection = new Observable <CollectionModel>(); DocumentsForSelectedCollection.SetChangesObservable(d => d.IndexChanges .Where(n => n.Name.Equals(CollectionsIndex, StringComparison.InvariantCulture)) .Select(m => Unit.Default)); DocumentsForSelectedCollection.DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, CollectionsIndex, new IndexQuery() { Query = "Tag:" + GetSelectedCollectionName() }); SelectedCollection.PropertyChanged += (sender, args) => { PutCollectionNameInTheUrl(); CollectionSource.CollectionName = GetSelectedCollectionName(); DocumentsForSelectedCollection.Context = "Collection/" + GetSelectedCollectionName(); }; SortedCollectionsList = new CollectionViewSource() { Source = Collections, SortDescriptions = { new SortDescription("Count", ListSortDirection.Descending) } }; }