public async void AddRemoveHandlerRegistry() { CreateMessageContext(); var document = DomOperationsTesting.CreateDocument(); var x = new MessageRegistry(document); var counter = 0; Task Handler(MessageEventArgs args) { counter++; return(Task.CompletedTask); } x.Add("a", Handler); await document.Head.NotifyEvent("_a"); Assert.Equal(1, counter); x.Remove("b", Handler); await document.Head.NotifyEvent("_a"); Assert.Equal(2, counter); x.Remove("a", Handler); await document.Head.NotifyEvent("_a"); Assert.Equal(2, counter); }
public void DocumentOnMessageRuns() { CreateMessageContext(); var doc = DomOperationsTesting.CreateDocument(); var counter = 0; Task Handler() { counter++; return(Task.CompletedTask); } doc.OnMessage("a", Handler); doc.Head.NotifyEvent("_a"); Assert.Equal(1, counter); }
public void DocumentProcessesMessageListeners() { CreateMessageContext(); var doc = DomOperationsTesting.CreateDocument(); var counter = 0; Task Handler(MessageEventArgs args) { counter++; return(Task.CompletedTask); } doc.AddMessageListener("a", Handler); doc.Head.NotifyEvent("_a"); Assert.Equal(1, counter); doc.RemoveMessageListener("a", Handler); doc.Head.NotifyEvent("_a"); Assert.Equal(1, counter); }