public void GetFilteredList()
        {
            DynamicsQuery query = new DynamicsQuery()
            {
                Table   = DynamicsTables.Systemuser,
                Filters = new List <Filter>()
                {
                    new Filter()
                    {
                        Field    = nameof(SystemUser.firstname),
                        Operator = FilterOperator.EqualsOperator,
                        Value    = FirstNameAnswer
                    },
                    new Filter {
                        Field          = nameof(SystemUser.lastname),
                        Operator       = FilterOperator.EqualsOperator,
                        Value          = LastNameAnswer,
                        GlobalOperator = FilterOperator.Or
                    }
                }
            };

            Task <DynamicsResponse <ICollection <SystemUser> > > task   = HttpFunctions.GetAsync <DynamicsResponse <ICollection <SystemUser> > >(connector.GetClient(), query.GetPath());
            DynamicsResponse <ICollection <SystemUser> >         answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            Assert.IsTrue(answer.value.Count > 0);
            Assert.IsTrue(answer.value.First().firstname.Equals(FirstNameAnswer) && answer.value.First().lastname.Equals(LastNameAnswer));
        }
Beispiel #2
0
        public FunctionDescriptor GetHttpFunctionOrNull(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (HttpFunctions == null || HttpFunctions.Count == 0)
            {
                return(null);
            }

            // Parse the route (e.g. "api/myfunc") to get 'myfunc"
            // including any path after "api/"
            FunctionDescriptor function = null;
            string             route    = HttpUtility.UrlDecode(uri.AbsolutePath);
            int idx = route.ToLowerInvariant().IndexOf("api", StringComparison.OrdinalIgnoreCase);

            if (idx > 0)
            {
                idx   = route.IndexOf('/', idx);
                route = route.Substring(idx + 1).Trim('/');

                HttpFunctions.TryGetValue(route.ToLowerInvariant(), out function);
            }

            return(function);
        }
        public void GetDataByIdAndExpand()
        {
            DynamicsQuery query = new DynamicsQuery
            {
                Table  = DynamicsTables.Contact,
                Key    = (string)TestContext.Properties["CONTACTID"],
                Fields = new List <string>()
                {
                    nameof(Contact.firstname)
                },
                Expand = new DynamicsQuery
                {
                    Key    = nameof(Contact.owninguser),
                    Fields = new List <string>()
                    {
                        nameof(SystemUser.firstname)
                    }
                }
            };
            Task <Contact> task   = HttpFunctions.GetAsync <Contact>(connector.GetClient(), query.GetPath());
            Contact        answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            Assert.IsTrue(answer.firstname.Equals(FirstNameAnswer));
            Assert.IsTrue(answer.owninguser.firstname.Equals(FirstNameAnswer));
        }
        public void GetList()
        {
            DynamicsQuery query = new DynamicsQuery
            {
                Table = DynamicsTables.Organization
            };
            Task <DynamicsResponse <ICollection <Organization> > > task   = HttpFunctions.GetAsync <DynamicsResponse <ICollection <Organization> > >(connector.GetClient(), query.GetPath());
            DynamicsResponse <ICollection <Organization> >         answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            Assert.IsTrue(answer.value.Count > 0);
        }
        public void GetLimitedList()
        {
            DynamicsQuery query = new DynamicsQuery
            {
                Table = DynamicsTables.Systemuser,
                Top   = 5
            };
            Task <DynamicsResponse <ICollection <SystemUser> > > task   = HttpFunctions.GetAsync <DynamicsResponse <ICollection <SystemUser> > >(connector.GetClient(), query.GetPath());
            DynamicsResponse <ICollection <SystemUser> >         answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            Assert.IsTrue(answer.value.Count == 5);
        }
        public void GetDataById()
        {
            DynamicsQuery query = new DynamicsQuery
            {
                Table = DynamicsTables.Systemuser,
                Key   = (string)TestContext.Properties["SYSTEMUSERID"]
            };
            Task <SystemUser> task   = HttpFunctions.GetAsync <SystemUser>(connector.GetClient(), query.GetPath());
            SystemUser        answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            Assert.IsTrue(answer.firstname.Equals(FirstNameAnswer));
        }
Beispiel #7
0
        public string GetDataFromSearchEngine(string url, string tagStartSplit, string tagEndSplit, int posArrayStartSplit = 1, int posArrayEndSplit = 0)
        {
            try
            {
                using var httpFuncions = new HttpFunctions();
                var resultSearchData = httpFuncions.ExecuteDynamicSearchEngineAsync(url).Result;

                tagStartSplit = StringFunctions.ParseTagValueToHtmlTag(tagStartSplit);
                tagEndSplit   = StringFunctions.ParseTagValueToHtmlTag(tagEndSplit);

                var rs = StringFunctions.ParserDataResultsSearch(resultSearchData, tagStartSplit, tagEndSplit, posArrayStartSplit, posArrayEndSplit);

                return(rs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void CrudAccount()
        {
            DynamicsQuery query = new DynamicsQuery
            {
                Table = DynamicsTables.Account
            };
            JObject account = JObject.FromObject(new Account()
            {
                name = "CrudTest �הצ"
            }, new JsonSerializer {
                NullValueHandling = NullValueHandling.Ignore
            });

            account["*****@*****.**"] = "/systemusers(" + SystemUserId + ")";
            Task <string> task   = HttpFunctions.CreateAsync(connector.GetClient(), query.GetPath(), JsonConvert.SerializeObject(account));
            string        answer = task.GetAwaiter().GetResult();

            Assert.IsTrue(answer != null);
            query.Key = answer;
            Task <bool> task2      = HttpFunctions.DeleteAsync <bool>(connector.GetClient(), query.GetPath());
            bool        boolAnswer = task2.GetAwaiter().GetResult();

            Assert.IsTrue(boolAnswer);
        }