Example #1
0
        public async Task Update_CustomFields()
        {
            var getCustomFieldResult = (await _collectionService.GetCustomFieldAsync(1, "jason.abc"));
            getCustomFieldResult.Error.Should().BeNull();
            
            var customField = getCustomFieldResult.ResultValue;
            customField.Should().NotBeNull();

            customField.Key = "jaSon";
            customField.Value = "false";

            var updateResult = (await _collectionService.UpdateCustomFieldAsync(customField));
            updateResult.Error.Should().BeNull();

            getCustomFieldResult = (await _collectionService.GetCustomFieldAsync(1, "jason"));
            getCustomFieldResult.Error.Should().BeNull();

            var newCustomField = getCustomFieldResult.ResultValue;
            newCustomField.Should().NotBeNull();

            newCustomField.Key.Should().Be(customField.Key);
            newCustomField.Value.Should().Be(customField.Value);

            //get new service instance
            //error test
            _collectionService = _container.Resolve<CollectionService>();

            getCustomFieldResult = (await _collectionService.GetCustomFieldAsync(1, "jason"));
            getCustomFieldResult.Error.Should().BeNull();

            customField = getCustomFieldResult.ResultValue;
            customField.Should().NotBeNull();
            customField.Key = "";
            customField.Value = string.Empty; //error

            updateResult = await _collectionService.UpdateCustomFieldAsync(customField);
            updateResult.Error.Should().NotBeNull();
            Console.WriteLine(updateResult.Error.Message);

        }