public UserOwnerResolverTests()
 {
     TunnelExtension     = Substitute.For <ITunnelExtension>();
     UserIdentity        = new Identity("user", "domain");
     ApplicationIdentity = new Identity("application", "domain");
     Application         = new Application()
     {
         Identifier = ApplicationIdentity.Name,
         Domain     = ApplicationIdentity.Domain
     };
     Message = new Message()
     {
         From = UserIdentity.ToNode(),
         To   = ApplicationIdentity.ToNode()
     };
     BuilderConfiguration = new BuilderConfiguration();
     TunnelIdentity       = new Identity(EnvelopeId.NewId(), Take.Blip.Client.Extensions.Tunnel.TunnelExtension.TunnelAddress.Domain);
     TunnelOwner          = new Identity("owner", "domain");
     TunnelExtension
     .GetTunnelAsync(TunnelIdentity, CancellationToken)
     .Returns(new Tunnel()
     {
         Owner       = TunnelOwner,
         Originator  = UserIdentity.ToNode(),
         Destination = ApplicationIdentity
     });
 }
        public async Task GetFromExtensionShouldSucceed()
        {
            // Arrange
            Message.From = TunnelIdentity.ToNode();
            TunnelExtension.GetTunnelAsync(TunnelIdentity, CancellationToken).Returns(Tunnel);

            var target = GetTarget();

            // Act
            var actualOriginator = await target.GetVariableAsync("originator", Context, CancellationToken);

            var actualOwner = await target.GetVariableAsync("owner", Context, CancellationToken);

            var actualDestination = await target.GetVariableAsync("destination", Context, CancellationToken);

            var actualIdentity = await target.GetVariableAsync("identity", Context, CancellationToken);

            // Assert
            actualOriginator.ShouldBe(Originator);
            actualOwner.ShouldBe(Owner);
            actualDestination.ShouldBe(ApplicationIdentity);
            actualIdentity.ShouldBe(TunnelIdentity);
        }
        public async Task GetFromExtensionWhenDoesNotExistsShouldReturnNull()
        {
            // Arrange
            Message.From = TunnelIdentity.ToNode();
            TunnelExtension.GetTunnelAsync(TunnelIdentity, CancellationToken)
            .Throws(new LimeException(ReasonCodes.COMMAND_RESOURCE_NOT_FOUND, "Not found"));

            var target = GetTarget();

            // Act
            var actualOriginator = await target.GetVariableAsync("originator", Context, CancellationToken);

            var actualOwner = await target.GetVariableAsync("owner", Context, CancellationToken);

            var actualDestination = await target.GetVariableAsync("destination", Context, CancellationToken);

            var actualIdentity = await target.GetVariableAsync("identity", Context, CancellationToken);

            // Assert
            actualOriginator.ShouldBeNull();
            actualOwner.ShouldBeNull();
            actualDestination.ShouldBeNull();
            actualIdentity.ShouldBeNull();
        }