public void TestFilter() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Systemuser, Filters = new List <Filter>() { new Filter() { Field = nameof(SystemUser.firstname), Operator = FilterOperator.EqualsOperator, Value = "Mirko" }, new Filter { Field = nameof(SystemUser.address1_addresstypecode), Operator = FilterOperator.EqualsOperator, Value = 1, GlobalOperator = FilterOperator.Or } }, Top = 5 }; Console.WriteLine(query.GetPath()); Assert.IsTrue(query.GetPath().Equals("systemusers?$filter=firstname eq 'Mirko' or address1_addresstypecode eq 1&$top=5")); }
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)); }
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 TestList() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Account }; Assert.IsTrue(query.GetPath().Equals("accounts")); }
public void TestSelectAndTop() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Systemuser, Top = 5 }; Assert.IsTrue(query.GetPath().Equals("systemusers?$top=5")); }
public void TestSingle() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Account, Key = "test" }; Assert.IsTrue(query.GetPath().Equals("accounts(test)")); }
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)); }
public void TestSingleSelect() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Systemuser, Key = "test", Fields = new List <string>() { nameof(SystemUser.firstname), nameof(SystemUser.lastname), nameof(SystemUser.address1_city) } }; Assert.IsTrue(query.GetPath().Equals("systemusers(test)?$select=firstname,lastname,address1_city")); }
public void ExpandFilter() { DynamicsQuery query = new DynamicsQuery { Table = DynamicsTables.Contact, Key = "contactId", Fields = new List <string>() { nameof(Contact.firstname), nameof(Contact.lastname) }, Expand = new DynamicsQuery { Key = nameof(Contact.owninguser), Fields = new List <string>() { nameof(SystemUser.firstname) } } }; Console.WriteLine(query.GetPath()); Assert.IsTrue(query.GetPath().Equals("contacts(contactId)?$select=firstname,lastname&$expand=owninguser($select=firstname)")); }
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); }