Пример #1
0
        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);
        }