public void CountsEqualSetsCorrectly() { var commandEvent = new CommandEvent { CommandId = "Test" }; var documentEvent = new DocumentEvent { Action = DocumentAction.Saved }; var concurrentEvent = new ConcurrentEvent { ConcurrentEventList = new List <IDEEvent> { commandEvent, documentEvent } }; _uut.OnEvent(concurrentEvent); _uut.OnEvent(concurrentEvent); Assert.AreEqual( 2, _uut.Statistic[ Sets.NewHashSet( EventMappingUtils.GetAbstractStringOf(documentEvent), EventMappingUtils.GetAbstractStringOf(commandEvent))]); }
private void ProcessDocumentEvent(DocumentEvent @event) { var isSave = @event.Action == DocumentAction.Saved; var activity = isSave ? Activity.Development : Activity.Navigation; InsertActivity(@event, activity); }
/* * if you review the type hierarchy of IDEEvent, you will realize that * several subclasses exist that provide access to context information that * is specific to the event type. * * To access the context, you should check for the runtime type of the event * and cast it accordingly. * * As soon as I have some more time, I will implement the visitor pattern to * get rid of the casting. For now, this is recommended way to access the * contents. */ private String process(IDEEvent e, out Completion vsEvent) { CommandEvent ce = e as CommandEvent; CompletionEvent compE = e as CompletionEvent; DocumentEvent docE = e as DocumentEvent; WindowEvent winE = e as WindowEvent; NavigationEvent navE = e as NavigationEvent; String developerId = ""; if (compE != null) { developerId = process(compE, out vsEvent); } //if (ce != null) developerId = process(ce, out vsEvent); //else if (docE != null) developerId = process(docE, out vsEvent); //else if (winE != null) developerId = process(winE, out vsEvent); //else if (navE != null) developerId = process(navE, out vsEvent); else { vsEvent = null; //developerId = processBasic(e, out vsEvent); } return(developerId); }
public void CollectsNameFromDocumentEvent() { var windowEvent = new DocumentEvent { Document = Names.Document("document event") }; Process(windowEvent); AssertNameCollected(windowEvent.Document); }
public void ShouldMapCloseToNavigation() { var @event = new DocumentEvent { Document = TestFixtures.SomeProductionDocumentName, Action = DocumentAction.Closing }; AssertMapsToActivity(@event, Activity.Navigation); }
public void ShouldMapSaveToDevelopment() { var @event = new DocumentEvent { Document = TestFixtures.SomeProductionDocumentName, Action = DocumentAction.Saved }; AssertMapsToActivity(@event, Activity.Development); }
/// <summary> /// Synchronizes the path of the Explorer Tool Window with /// the path of this document. /// </summary> private void OnSyncPathToExplorerCommand() { try { DocumentEvent?.Invoke(this, new FileBaseEvent(FileEventType.AdjustCurrentPath)); } catch { } }
public void ShouldSerializeToString() { var e = new DocumentEvent { Action = DocumentAction.Saved, Document = Names.Document("x SomeProcessedDocument") }; const string expected = "{\"$type\":\"KaVE.Commons.Model.Events.VisualStudio.DocumentEvent, KaVE.Commons\",\"Document\":\"0Doc:x SomeProcessedDocument\",\"Action\":1,\"TriggeredBy\":0}"; JsonAssert.SerializesTo(e, expected); JsonAssert.DeserializesTo(expected, e); }
public void ReplacesDocumentClosingEventWithCloseEventTest() { var closingEvent = new DocumentEvent { Action = DocumentAction.Closing }; var resultSet = _uut.Map(closingEvent); var expected = new CommandEvent { CommandId = "Close" }; CollectionAssert.AreEquivalent(new[] { expected }, resultSet); }
private void ProcessDocumentEvent(DocumentEvent documentEvent) { if (_addedNewItem) { _addedNewItem = false; var solutionEvent = new SolutionEvent { Action = SolutionAction.AddProjectItem, Target = documentEvent.Document }; solutionEvent.CopyIDEEventPropertiesFrom(documentEvent); Insert(solutionEvent); } }
public void FiltersDocumentCloseAfterCommandClose() { var commandCloseEvent = new CommandEvent { CommandId = "Close" }; _uut.Map(commandCloseEvent); var documentEvent = new DocumentEvent { Action = DocumentAction.Closing }; var processedEvent = _uut.Map(documentEvent); CollectionAssert.IsEmpty(processedEvent); }
private String process(DocumentEvent de, out Event cmd) { //writer.WriteLine("found a CommandEvent (id: " + ce.CommandId + ")"); cmd = new DocuemntCmd(de.Action.ToString()); if (de.Document != null) { ((DocuemntCmd)cmd).docName = de.Document.FileName; } if (de.ActiveDocument != null) { ((DocuemntCmd)cmd).docName = de.ActiveDocument.FileName; } cmd.triggeredAt = de.TriggeredAt; return(de.IDESessionUUID); }
public void ResetsForNewDeveloper() { var addNewItemCommandEvent = new CommandEvent { CommandId = "AddNewItem" }; var documentEvent = new DocumentEvent { Document = Names.Document("CSharp Test.cs") }; _uut.Map(addNewItemCommandEvent); _uut.OnStreamEnds(); _uut.OnStreamStarts(TestFactory.SomeDeveloper()); var actuals = _uut.Map(documentEvent); CollectionAssert.AreEqual(new[] { documentEvent }, actuals); }
private void ProcessDocumentEvent(DocumentEvent documentEvent) { if (_filterNextDocumentEvent) { _filterNextDocumentEvent = false; DropCurrentEvent(); } else { if (documentEvent.Action == DocumentAction.Closing) { var commandEvent = new CommandEvent { CommandId = "Close" }; commandEvent.CopyIDEEventPropertiesFrom(documentEvent); ReplaceCurrentEventWith(commandEvent); } } }
public void GenerateSolutionEventTest(string documentIdentifier, string commandId) { var addNewItemCommandEvent = new CommandEvent { CommandId = commandId }; var documentEvent = new DocumentEvent { Document = Names.Document(documentIdentifier) }; _uut.Map(addNewItemCommandEvent); var actuals = _uut.Map(documentEvent); var expectedSolutionEvent = new SolutionEvent { Target = documentEvent.Document, Action = SolutionAction.AddProjectItem }; CollectionAssert.AreEquivalent(new IDEEvent[] { documentEvent, expectedSolutionEvent }, actuals); }
public virtual void InsertUpdate(DocumentEvent e) { lock (this) { int len = e.GetLength(); int off = e.GetOffset(); if (outputMark > off) { outputMark += len; } } }
/// <summary> /// Forwards the <code>DocumentEvent</code> to the give child view. /// </summary> protected void forwardUpdateToView(View @v, DocumentEvent @e, Shape @a, ViewFactory @f) { }
/// <summary> /// Gives notification from the document that attributes were changed /// in a location that this view is responsible for. /// </summary> public void changedUpdate(DocumentEvent @e, Shape @a, ViewFactory @f) { }
/// <summary> /// Gives notification that something was removed from the document /// in a location that this view is responsible for. /// </summary> public void removeUpdate(DocumentEvent @e, Shape @a, ViewFactory @f) { }
public virtual void RemoveUpdate(DocumentEvent e) { lock (this) { int len = e.GetLength(); int off = e.GetOffset(); if (outputMark > off) { if (outputMark >= off + len) { outputMark -= len; } else { outputMark = off; } } } }
public virtual void ChangedUpdate(DocumentEvent e) { lock (this) { } }
/// <summary> /// Gives notification that something was inserted into /// the document in a location that this view is responsible for. /// </summary> public void insertUpdate(DocumentEvent @e, Shape @a, ViewFactory @f) { }
/// <summary> /// This method is executed to tell the surrounding framework to close the document. /// </summary> protected virtual void OnClose() { DocumentEvent?.Invoke(this, new FileBaseEvent(FileEventType.CloseDocument)); }