Exemplo n.º 1
0
        public void SetsIntegerProperty()
        {
            var obj  = _fke.SampleClass1();
            var dict = D8NodeMapper.Cast(obj, "");

            dict.MustHave("field_first_number", "value", obj.FirstNumber);
        }
Exemplo n.º 2
0
        public void SetsTextProperty()
        {
            var obj  = _fke.SampleClass1();
            var dict = D8NodeMapper.Cast(obj, "");

            dict.MustHave("field_first_text", "value", obj.FirstText);
        }
Exemplo n.º 3
0
        public void SetsContentType()
        {
            var obj  = _fke.SampleClass1();
            var dict = D8NodeMapper.Cast(obj, "");

            dict.MustHave("type", "target_id", obj.D8TypeName);
        }
Exemplo n.º 4
0
        public void SetsContentTitle()
        {
            var obj  = _fke.SampleClass1();
            var dict = D8NodeMapper.Cast(obj, "");

            dict.MustHave("title", "value", obj.TheTitle);
        }
Exemplo n.º 5
0
        public async Task <NodeReply> PatchNode <T>(T node, CancellationToken cancelTkn, string revisionLog)
            where T : ID8Node
        {
            var url = string.Format(D8.NODE_X_FORMAT_HAL, node.nid);
            //var url  = string.Format(D8.NODE_X_REV_Y_FMT_HAL, node.nid, node.vid);
            var mapd = D8NodeMapper.Cast(node, BaseURL);

            if (!revisionLog.IsBlank())
            {
                var now = DateTime.Now.ToString("d MMM yyyy, h:mmtt");
                var log = $"[{Creds.Username}, {now}] {revisionLog}";
                mapd.Add("revision_log", D8HALJson.ValueField(log));
            }


            Dictionary <string, object> dict;

            try
            {
                dict = await BasicAuthPATCH
                       <Dictionary <string, object> >(url, mapd, cancelTkn);

                return(new NodeReply(dict));
            }
            catch (Exception ex)
            {
                return(NodeReply.Fail(ex));
            }
        }
Exemplo n.º 6
0
        public void MapsNullableDateProperty_null()
        {
            var node = new TestClass {
                Date2 = null
            };
            var mapd = D8NodeMapper.Cast(node, "");

            mapd.MustHave("field_date2", "value", null);
        }
Exemplo n.º 7
0
        public void MapsNullableDateProperty()
        {
            var node = new TestClass {
                Date2 = 23.February(2016)
            };
            var mapd = D8NodeMapper.Cast(node, "");

            mapd.MustHave("field_date2", "value", node.Date2?.ToString("yyyy-MM-dd"));
        }
Exemplo n.º 8
0
        public void MapsStringProperty()
        {
            var node = new TestClass {
                Text1 = "abc"
            };
            var mapd = D8NodeMapper.Cast(node, "");

            mapd.MustHave("field_text1", "value", node.Text1);
        }
Exemplo n.º 9
0
        protected Task <Dictionary <string, object> > PostNode <T>(T objectToPost, Func <Task <T> > postedNodeGetter)
            where T : D8NodeBase
        {
            var node = D8NodeMapper.Cast(objectToPost, Credentials.ApiBaseURL);

            //node.Remove("field_package");

            //todo: pass D8 SavedIDsCopier to PostTilOK
            return(PostTilOK <T>(node, "entity/node?_format=hal_json", postedNodeGetter, null));
        }
Exemplo n.º 10
0
        public async Task <NodeReply> PostNode <T>(T node, CancellationToken cancelTkn)
            where T : ID8Node
        {
            var url  = D8.NODE_FORMAT_HAL;
            var mapd = D8NodeMapper.Cast(node, BaseURL);
            var dict = await BasicAuthPOST
                       <Dictionary <string, object> >(url, mapd, cancelTkn);

            return(new NodeReply(dict));
        }