Example #1
0
        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);
        }
Example #2
0
        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 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);
 }
Example #4
0
        public void AddItemsToNullPropertyTest()
        {
            APObject obj = new APObject("object");

            obj.AddItems("field1", 5, 6);
            Assert.IsTrue(obj.GetList <string>("field1").Count() == 2);
        }
Example #5
0
        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 AddItemsToMultiValuedFieldAsyncTest()
        {
            var obj = new APObject("object");
            await obj.SaveAsync();

            await obj.AddItemsAsync("multifield", "1", "2", "3");

            var list = obj.GetList <string>("multifield");

            Assert.IsTrue(list.Except(new[] { "1", "2", "3" }).Count() == 0);
        }
Example #7
0
        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 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 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 AddItemsToMultiValuedFieldAsyncTest()
 {
     var obj = new APObject("object");
     await obj.SaveAsync();
     await obj.AddItemsAsync("multifield", "1", "2", "3");
     var list = obj.GetList<string>("multifield");
     Assert.IsTrue(list.Except(new[] { "1", "2", "3" }).Count() == 0);
 }