예제 #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>());
        }