public void AddShouldThrowIfUriHasBeenRegisteredToAnotherType()
        {
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/tests");
            sut.Add<TestMessage>(uri);

            Assert.Throws<SkuttException>(() => sut.Add<TestMessage2>(uri));
        }
        public void AddShouldThrowIfTypeHasBeenRegisteredAgainstAnotherUri()
        {
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/test_message");
            sut.Add<TestMessage>(uri);

            Assert.Throws<SkuttException>(() => sut.Add<TestMessage>(new Uri("http://messages.skutt.net/test_message2")));
        }
        public void AddShouldThrowIfTypeHasBeenRegisteredAgainstAnotherUri()
        {
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/test_message");

            sut.Add <TestMessage>(uri);

            Assert.Throws <SkuttException>(() => sut.Add <TestMessage>(new Uri("http://messages.skutt.net/test_message2")));
        }
        public void AddShouldThrowIfUriHasBeenRegisteredToAnotherType()
        {
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/tests");

            sut.Add <TestMessage>(uri);

            Assert.Throws <SkuttException>(() => sut.Add <TestMessage2>(uri));
        }
        public void AddedMappingShouldBeRetrievableAsFromType()
        {
            //Arrange
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/tests");

            //Act
            sut.Add<TestMessage>(uri);

            //Assert
            Assert.Equal(uri, sut.GetUri<TestMessage>());
            Assert.Equal(typeof(TestMessage), sut.GetType(uri));
            Assert.Equal(typeof(TestMessage), sut.GetType("http://messages.skutt.net/tests"));
        }
        public void AddedMappingShouldBeRetrievableAsFromType()
        {
            //Arrange
            var sut = new MessageTypeRegistry();
            var uri = new Uri("http://messages.skutt.net/tests");

            //Act
            sut.Add <TestMessage>(uri);

            //Assert
            Assert.Equal(uri, sut.GetUri <TestMessage>());
            Assert.Equal(typeof(TestMessage), sut.GetType(uri));
            Assert.Equal(typeof(TestMessage), sut.GetType("http://messages.skutt.net/tests"));
        }
Example #7
0
        public async void AddRemoveHandler()
        {
            var x       = new MessageTypeRegistry();
            var counter = 0;

            Task Handler(MessageEventArgs args1)
            {
                Assert.Equal("test", args1.Body);
                counter++;
                return(Task.CompletedTask);
            }

            x.Add(Handler);
            var args = new MessageEventArgs("test");
            await x.RunAll(args);

            Assert.Equal(1, counter);
            x.Remove(Handler);
            await x.RunAll(args);

            Assert.Equal(1, counter);
        }