Esempio n. 1
0
        public async Task Can_perform_mutate_in_with_array()
        {
            var collection = await _fixture.GetDefaultCollection();

            await collection.Upsert(DocumentKey, new { foo = "bar", bar = "foo" });

            await collection.MutateIn(DocumentKey, new[]
            {
                MutateInSpec.Upsert("name", "mike"),
                MutateInSpec.Replace("bar", "bar")
            });

            var getResult = await collection.Get(DocumentKey);

            var content = getResult.ContentAs <string>();

            var expected = new
            {
                foo  = "bar",
                bar  = "bar",
                name = "mike"
            };

            Assert.Equal(JsonConvert.SerializeObject(expected), content);
        }
        public async Task Can_perform_mutate_in_with_array()
        {
            var collection = await _fixture.GetDefaultCollection().ConfigureAwait(false);

            await collection.UpsertAsync(DocumentKey, new { foo = "bar", bar = "foo" }).ConfigureAwait(false);

            var result = await collection.MutateInAsync(DocumentKey, new[]
            {
                MutateInSpec.Upsert("name", "mike"),
                MutateInSpec.Replace("bar", "bar")
            }).ConfigureAwait(false);

            using var getResult = await collection.GetAsync(DocumentKey, options => options.Transcoder(new LegacyTranscoder())).ConfigureAwait(false);

            var content = getResult.ContentAs <string>();

            var expected = new
            {
                foo  = "bar",
                bar  = "bar",
                name = "mike"
            };

            Assert.Equal(JsonConvert.SerializeObject(expected), content);
        }