Пример #1
0
        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"));
        }
Пример #2
0
        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"));
        }
Пример #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;
            }
        }
Пример #4
0
        public void GetUri_ShouldThrowWhenNoRegistryAdded()
        {
            var sut = new MessageTypeRegistry();

            Assert.Throws<SkuttException>(() => sut.GetUri<TestMessage>());
        }
Пример #5
0
        public void GetUri_ShouldThrowWhenNoRegistryAdded()
        {
            var sut = new MessageTypeRegistry();

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