コード例 #1
0
ファイル: FimClient.cs プロジェクト: Predica/FimClient
        public RmResource FindById(string id, AttributesToFetch attributes = null)
        {
            Initialize();

            attributes = attributes ?? AttributesToFetch.All;

            var ctx = LogContext.WithConfigFormat();

            _log.Debug(ctx.Format("Finding object by id {0} with attributes {1}"), id, attributes.GetNames().ToJSON());

            RmResource resource = null;

            try
            {
                var reference = new RmReference(id);

                if (attributes != AttributesToFetch.All)
                {
                    attributes = attributes.AppendAttribute(RmResource.AttributeNames.ObjectType.Name);
                }

                resource = _defaultClient.Get(reference, attributes.GetNames());

                _log.Debug(ctx.Format("Found object with id {0}, type {1}"), id, resource.ObjectType);
            }
            catch
            {
                // catching exc - meaning that object not found

                _log.Warn(ctx.Format("Object with id {0} not found"), id);
            }
            return(resource);
        }
コード例 #2
0
        public void can_append_names_to_empty_names_list()
        {
            var attributes = new AttributesToFetch();

            var newAttributes = attributes.AppendAttribute("attr1");

            var names = newAttributes.GetNames();

            Assert.Equal(new[] { "attr1" }, names);
        }
コード例 #3
0
        public void appends_new_name_to_the_list_and_creates_new_instance()
        {
            var attributes = new AttributesToFetch("attr1");

            var newAttributes = attributes.AppendAttribute("attr2");

            var names = newAttributes.GetNames();

            Assert.Equal(new[] { "attr1", "attr2" }, names);
        }
コード例 #4
0
        public void does_not_append_duplicate_names()
        {
            var attributes = new AttributesToFetch("attr1", "attr2");

            var newAttributes = attributes.AppendAttribute("attr2");

            var names = newAttributes.GetNames();

            Assert.Equal(new[] { "attr1", "attr2" }, names);
        }
コード例 #5
0
        public void does_not_modify_original_instance()
        {
            var attributes = new AttributesToFetch("attr1");

            attributes.AppendAttribute("attr2");

            var names = attributes.GetNames();

            Assert.Equal(new[] { "attr1" }, names);
        }