public void GetListTest() { var obj = new APObject("object"); obj.SetList<int>("multifield", new[] { 1, 2, 3, 4, 5 }); var list = obj.GetList<decimal>("multifield"); Assert.IsTrue(list.Intersect(new decimal[] { 1, 2, 3, 4, 5 }).Count() == 5); }
public void GetListTest() { var obj = new APObject("object"); obj.SetList <int>("multifield", new[] { 1, 2, 3, 4, 5 }); var list = obj.GetList <decimal>("multifield"); Assert.IsTrue(list.Intersect(new decimal[] { 1, 2, 3, 4, 5 }).Count() == 5); }
public async Task SaveMultivaluedAsyncTest() { var array = new[] { 1, 3, 4, 5, 6, 7 }; var obj = new APObject("object"); obj.SetList<int>("multifield", array); await obj.SaveAsync(); var saved = await APObjects.GetAsync("object", obj.Id); var array2 = saved.GetList<int>("multifield"); Assert.IsTrue(array.Intersect(array2).Count() == array.Length); }
public void ItemAddTestWithoutDuplication() { APObject obj = new APObject("object"); obj.SetList <int>("field1", new[] { 1, 2, 3, 4, 5, 6 }); var field1 = obj.GetList <int>("field1"); Assert.IsTrue(field1.Count() == 6); obj.AddItems("field1", false, 5, 6); field1 = obj.GetList <int>("field1"); Assert.IsTrue(field1.Count() == 6); }
public void RemoveAllOccurencesOfItemTest() { APObject obj = new APObject("object"); obj.SetList <int>("field1", new[] { 1, 2, 3, 1, 2, 3 }); var removed = obj.RemoveItems("field1", 1, false); Assert.IsTrue(removed == true); var list = obj.GetList <int>("field1").ToList(); Assert.IsTrue(list.Count == 4); Assert.IsTrue(list.Count(x => x == 1) == 0); }
public async Task MultiValueObjectTest() { var obj = new APObject("object"); obj.SetList <string>("multifield", new[] { "1", "2", "3", "4" }); await obj.SaveAsync(); var read = await APObjects.GetAsync("object", obj.Id); var value = read.GetList <string>("multifield"); var strList = read.GetList <string>("multifield"); var intList = read.GetList <int>("multifield"); }
public void ItemAddTest() { APObject obj = new APObject("object"); obj.SetList <int>("field1", new[] { 1, 2, 3, 4, 5, 6 }); var field1 = obj.GetList <int>("field1"); Assert.IsFalse(field1.Contains(10)); Assert.IsFalse(field1.Contains(11)); obj.AddItems("field1", 10, 11); field1 = obj.GetList <int>("field1"); Assert.IsTrue(field1.Contains(10)); Assert.IsTrue(field1.Contains(11)); }
public async Task RemoveItemsFromMultiValuedFieldAsyncTest() { var obj = new APObject("object"); obj.SetList("multifield", new int[] { 1, 2, 3 }); await obj.SaveAsync(); await obj.RemoveItemsAsync("multifield", "1", "2"); var list = obj.GetList <string>("multifield"); Assert.IsTrue(list.Count() == 1); Assert.IsTrue(list.Except(new[] { "3" }).Count() == 0); }
public async Task AddUniqueItemsToMultiValuedFieldAsyncTest() { var obj = new APObject("object"); obj.SetList("multifield", new int[] { 1, 2, 3 }); await obj.SaveAsync(); await obj.AddItemsAsync("multifield", true, "1", "2", "3", "4", "5"); var list = obj.GetList <string>("multifield"); Assert.IsTrue(list.Count() == 5); Assert.IsTrue(list.Except(new[] { "1", "2", "3", "4", "5" }).Count() == 0); }
public async Task SaveMultivaluedAsyncTest() { var array = new[] { 1, 3, 4, 5, 6, 7 }; var obj = new APObject("object"); obj.SetList <int>("multifield", array); await obj.SaveAsync(); var saved = await APObjects.GetAsync("object", obj.Id); var array2 = saved.GetList <int>("multifield"); Assert.IsTrue(array.Intersect(array2).Count() == array.Length); }
public void CannotGetMultiValuedViaIndexerTest() { var obj = new APObject("object"); try { obj.SetList<int>("multifield", new int[] { 1, 2, 4 }); try { var list = obj["multifield"]; Assert.Fail("Set operation on multivalue indexer should have failed."); } catch (Exception) { } } catch (Exception) { } }
public void CannotGetMultiValuedViaIndexerTest() { var obj = new APObject("object"); try { obj.SetList <int>("multifield", new int[] { 1, 2, 4 }); try { var list = obj["multifield"]; Assert.Fail("Set operation on multivalue indexer should have failed."); } catch (Exception) { } } catch (Exception) { } }
public async Task MultiValueObjectTest() { var obj = new APObject("object"); obj.SetList<string>("multifield", new[] { "1", "2", "3", "4" }); await obj.SaveAsync(); var read = await APObjects.GetAsync("object", obj.Id); var value = read.GetList<string>("multifield"); var strList = read.GetList<string>("multifield"); var intList = read.GetList<int>("multifield"); }
public async Task RemoveItemsFromMultiValuedFieldAsyncTest() { var obj = new APObject("object"); obj.SetList("multifield", new int[] { 1, 2, 3 }); await obj.SaveAsync(); await obj.RemoveItemsAsync("multifield", "1", "2"); var list = obj.GetList<string>("multifield"); Assert.IsTrue(list.Count() == 1); Assert.IsTrue(list.Except(new[] { "3" }).Count() == 0); }
public async Task AddUniqueItemsToMultiValuedFieldAsyncTest() { var obj = new APObject("object"); obj.SetList("multifield", new int[] { 1, 2, 3 }); await obj.SaveAsync(); await obj.AddItemsAsync("multifield", true, "1", "2", "3", "4", "5"); var list = obj.GetList<string>("multifield"); Assert.IsTrue(list.Count() == 5); Assert.IsTrue(list.Except(new[] { "1", "2", "3", "4", "5" }).Count() == 0); }
public async Task FindObjectsWithInQueryForMultiValuedPropertyTest() { var value = Unique.String; var queryValues = new[] { Unique.String, value, Unique.String, Unique.String }; var obj = new APObject("object"); obj.SetList("multifield", new [] { value, Unique.String }); obj = await ObjectHelper.CreateNewAsync(obj); var results = await APObjects.FindAllAsync("object", Query.Property("multifield").IsIn(queryValues), sortOrder: SortOrder.Descending, orderBy: "__id", pageSize: 5); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results.Single().Id == obj.Id); }