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"));
        }
Beispiel #3
0
        public void Send <TCommand>(string destination, TCommand command)
        {
            Preconditions.Require(destination, "destination");
            Preconditions.Require(command, "command");

            var messageTypeUri = registry.GetUri <TCommand>();

            try
            {
                using (var channel = ChannelFactory.PointToPointSend(destination))
                {
                    channel.Put(MessageSerializer.SerializeDefault(command, messageTypeUri), messageTypeUri.ToString());
                }
            }
            catch (OperationInterruptedException oie)
            {
                throw new SkuttException(
                          string.Format("Queue: {0} does not exist so you can't send a command to it", destination), oie);
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public void GetUri_ShouldThrowWhenNoRegistryAdded()
        {
            var sut = new MessageTypeRegistry();

            Assert.Throws<SkuttException>(() => sut.GetUri<TestMessage>());
        }
        public void GetUri_ShouldThrowWhenNoRegistryAdded()
        {
            var sut = new MessageTypeRegistry();

            Assert.Throws <SkuttException>(() => sut.GetUri <TestMessage>());
        }