Exemple #1
0
        public void TypedAsThrowsIfCommandIsNotAssignableToType()
        {
            var sut = new CommandEnvelope()
                      .SetCommand(Command)
                      .SetCommandId(CommandId)
                      .SetCorrelationId(CorrelationId)
                      .SetSourceId(SourceId)
                      .SetMetadata(Metadata)
                      .SetPrincipal(Principal);

            Assert.Throws <InvalidCastException>(() => sut.TypedAs <Message>());
        }
Exemple #2
0
        public void TypedAsDoesNotThrowIfCommandIsAssignableToType()
        {
            var message = new Message();
            var sut     = new CommandEnvelope()
                          .SetCommand(message)
                          .SetCommandId(CommandId)
                          .SetCorrelationId(CorrelationId)
                          .SetSourceId(SourceId)
                          .SetMetadata(Metadata)
                          .SetPrincipal(Principal);

            var result = sut.TypedAs <object>();

            Assert.IsType <CommandEnvelope <object> >(result);
            Assert.Same(message, result.Command);
            Assert.Equal(CommandId, result.CommandId);
            Assert.Equal(CorrelationId, result.CorrelationId);
            Assert.Equal(SourceId, result.SourceId);
            Assert.Same(Metadata, result.Metadata);
            Assert.Same(Principal, result.Principal);
        }
Exemple #3
0
        public void TypedAsReturnsExpectedInstance()
        {
            var message = new Message();
            var sut     = new CommandEnvelope()
                          .SetCommand(message)
                          .SetCommandId(CommandId)
                          .SetCorrelationId(CorrelationId)
                          .SetSourceId(SourceId)
                          .SetMetadata(Metadata)
                          .SetPrincipal(Principal);

            var result = sut.TypedAs <Message>();

            Assert.IsType <CommandEnvelope <Message> >(result);
            Assert.Same(message, result.Command);
            Assert.Equal(CommandId, result.CommandId);
            Assert.Equal(CorrelationId, result.CorrelationId);
            Assert.Equal(SourceId, result.SourceId);
            Assert.Same(Metadata, result.Metadata);
            Assert.Same(Principal, result.Principal);
        }