Esempio n. 1
0
        public async Task CreatePairedAgentsWithRouting()
        {
            var pair = await InProcAgent.CreatePairedWithRoutingAsync();

            var connections1 = await pair.Agent1.Connections.ListAsync(pair.Agent1.Context);

            var invitation1 = connections1.FirstOrDefault(x => x.State == ConnectionState.Invited);

            var connection1 = connections1.FirstOrDefault(x => x.Id != invitation1.Id);
            var connection2 = (await pair.Agent2.Connections.ListAsync(pair.Agent2.Context)).FirstOrDefault();

            var provisioning1 = await pair.Agent1.Host.Services.GetRequiredService <IProvisioningService>()
                                .GetProvisioningAsync(pair.Agent1.Context.Wallet);

            var provisioning2 = await pair.Agent2.Host.Services.GetRequiredService <IProvisioningService>()
                                .GetProvisioningAsync(pair.Agent2.Context.Wallet);

            // Connections exist
            Assert.NotNull(invitation1);
            Assert.NotNull(connection1);
            Assert.NotNull(connection2);

            // The two connections are connected in the correct state
            Assert.Equal(ConnectionState.Connected, connection1.State);
            Assert.Equal(ConnectionState.Connected, connection2.State);

            // Check mediator and edge provisioning record states
            Assert.Equal(provisioning1.GetTag(MediatorProvisioningService.EdgeInvitationTagName), invitation1.Id);
            Assert.Equal(provisioning2.GetTag(EdgeProvisioningService.MediatorConnectionIdTagName), connection2.Id);
        }
Esempio n. 2
0
        public async Task InitializeAsync()
        {
            // Agent1 - Mediator
            // Agent2 - Edge
            Pair = await InProcAgent.CreatePairedWithRoutingAsync();

            // WalletService = Pair.Agent2.Host.Services.GetRequiredService<IWalletService>();
            EdgeClient      = Pair.Agent2.Host.Services.GetRequiredService <IEdgeClientService>();
            WalletService   = Pair.Agent2.Host.Services.GetRequiredService <IWalletService>();
            AgentOptions    = Pair.Agent2.Host.Services.GetRequiredService <IOptions <AgentOptions> >().Value;
            EdgeContext     = Pair.Agent2.Context;
            MediatorContext = Pair.Agent1.Context;
        }
        public async Task CreatePairedAgentsWithRoutingAndMetadata()
        {
            Dictionary <string, string> metaData = new Dictionary <string, string>()
            {
                { "tag", "value" }
            };
            var pair = await InProcAgent.CreatePairedWithRoutingAsync(metaData);

            var connections1 = await pair.Agent1.Connections.ListAsync(pair.Agent1.Context);

            var invitation1 = connections1.FirstOrDefault(x => x.State == ConnectionState.Invited);

            var connection1 = connections1.FirstOrDefault(x => x.Id != invitation1.Id);
            var connection2 = (await pair.Agent2.Connections.ListAsync(pair.Agent2.Context)).FirstOrDefault();

            var provisioning1 = await pair.Agent1.Host.Services.GetRequiredService <IProvisioningService>()
                                .GetProvisioningAsync(pair.Agent1.Context.Wallet);

            var provisioning2 = await pair.Agent2.Host.Services.GetRequiredService <IProvisioningService>()
                                .GetProvisioningAsync(pair.Agent2.Context.Wallet);

            // Connections exist
            invitation1.Should().NotBeNull();
            connection1.Should().NotBeNull();
            connection2.Should().NotBeNull();

            // The two connections are connected in the correct state
            ConnectionState.Connected.Should().Be(connection1.State);
            ConnectionState.Connected.Should().Be(connection2.State);

            // Check mediator and edge provisioning record states
            provisioning1.GetTag(MediatorProvisioningService.EdgeInvitationTagName).Should().Be(invitation1.Id);
            provisioning2.GetTag(EdgeProvisioningService.MediatorConnectionIdTagName).Should().Be(connection2.Id);

            string inboxId = connection1.GetTag("InboxId");
            IWalletRecordService recordService = pair.Agent1.Host.Services.GetRequiredService <IWalletRecordService>();
            InboxRecord          inboxRecord   = await recordService.GetAsync <InboxRecord>(pair.Agent1.Context.Wallet, inboxId);

            inboxRecord.GetTag("tag").Should().Be(metaData["tag"]);
        }