Beispiel #1
0
        public void CanUpdateMetadata()
        {
            // arrange
            var client     = new ChestClient(this.ServiceUrl, new[] { new SuccessHandler() });
            var category   = "Integration";
            var collection = "Tests";
            var key        = "456988";

            var expected = new MetadataModel
            {
                Data = new Dictionary <string, string>
                {
                    { "accountNumber", key },
                    { "marginAccount", "MA02" },
                    { "referenceAccount", "RF12" },
                    { "bankIdentificationReference", "BIR12" },
                }
            };

            MetadataModel actual = null;

            $"Given the metadata for category: {category} collection: {collection} key: {key}"
            .x(async() =>
            {
                await client.Metadata.AddAsync(category, collection, key, expected).ConfigureAwait(false);
            });

            $"When try to update metadata for the category: {category} collection: {collection} key: {key}"
            .x(async() =>
            {
                expected.Data = new Dictionary <string, string>
                {
                    { "accountNumber", key },
                    { "referenceAccount", "SomeNewRef" }
                };

                await client.Metadata.UpdateAsync(category, collection, key, expected).ConfigureAwait(false);
            });

            $"And try to get metadata for the category: {category} collection: {collection} key: {key}"
            .x(async() =>
            {
                actual = await client.Metadata.GetAsync(category, collection, key).ConfigureAwait(false);
            });

            "Then the fetched metadata should be same as updated metadata"
            .x(() =>
            {
                Assert.NotNull(actual);
                actual.Should().BeEquivalentTo(expected);
            });
        }