Esempio n. 1
0
        public async Task GetConfigurationAsync_WithNullMetadata_ValidateRequest()
        {
            await using var client = TestClient.CreateForDaprClient();
            var request = await client.CaptureGrpcRequestAsync(async daprClient =>
            {
                return(await daprClient.GetConfiguration("testStore", new List <string>()
                {
                    "test_key"
                }));
            });

            // Get Request and validate
            var envelope = await request.GetRequestEnvelopeAsync <Autogenerated.GetConfigurationRequest>();

            envelope.StoreName.Should().Be("testStore");
            envelope.Keys.Should().Contain("test_key");
            envelope.Metadata.Count.Should().Be(0);

            // Get response and validate
            var invokeResponse = new Autogenerated.GetConfigurationResponse();

            invokeResponse.Items.Add(new Autogenerated.ConfigurationItem()
            {
                Key     = "testKey",
                Value   = "testValue",
                Version = "v1"
            });

            var domainResponse = await request.CompleteWithMessageAsync(invokeResponse);

            domainResponse.Items.Count.Should().Be(1);
            domainResponse.Items[0].Value.Should().Be("testValue");
            domainResponse.Items[0].Version.Should().Be("v1");
        }
Esempio n. 2
0
        public async Task GetConfigurationAsync_WithNullKeys_ValidateRequest()
        {
            await using var client = TestClient.CreateForDaprClient();
            var metadata = new Dictionary <string, string>
            {
                { "key1", "value1" },
                { "key2", "value2" }
            };
            var request = await client.CaptureGrpcRequestAsync(async daprClient =>
            {
                return(await daprClient.GetConfiguration("testStore", null, metadata));
            });

            // Get Request and validate
            var envelope = await request.GetRequestEnvelopeAsync <Autogenerated.GetConfigurationRequest>();

            envelope.StoreName.Should().Be("testStore");
            envelope.Keys.Should().BeEmpty();
            envelope.Metadata.Count.Should().Be(2);
            envelope.Metadata.Keys.Contains("key1").Should().BeTrue();
            envelope.Metadata.Keys.Contains("key2").Should().BeTrue();
            envelope.Metadata["key1"].Should().Be("value1");
            envelope.Metadata["key2"].Should().Be("value2");

            // Get response and validate
            var invokeResponse = new Autogenerated.GetConfigurationResponse();

            invokeResponse.Items.Add(new Autogenerated.ConfigurationItem()
            {
                Key     = "testKey",
                Value   = "testValue",
                Version = "v1"
            });

            var domainResponse = await request.CompleteWithMessageAsync(invokeResponse);

            domainResponse.Items.Count.Should().Be(1);
            domainResponse.Items[0].Value.Should().Be("testValue");
            domainResponse.Items[0].Version.Should().Be("v1");
        }