public void WhereCol1()
        {
            var result = ClassWithCollection.CreateQuery().OData().Filter("Link2/any(s: s/Id eq 311)").ToArray();

            Assert.Single((IEnumerable)result);
            Assert.Equal(31, result[0].Id);
        }
Ejemplo n.º 2
0
        public void SerializeSelectExpand2()
        {
            JToken token = ClassWithCollection.CreateQuery().OData().SelectExpand("Name", "Link2($filter=Id eq 311;$select=Name)").ToJson();

            Assert.NotNull(token);

            Assert.DoesNotContain("ModelID", token.ToString(Formatting.None));
        }
        public void ExpandCollectionWithTopDefaultPageSize()
        {
            ISelectExpandWrapper[] result = ClassWithCollection.CreateQuery().OData(s => s.QuerySettings.PageSize = 1).SelectExpand("Name", "Link2").ToArray();

            IDictionary <string, object> metadata = result[0].ToDictionary();

            // Not expanded by default
            Assert.Equal(2, metadata.Count);
            Assert.Single((metadata["Link2"] as IEnumerable <ISelectExpandWrapper>));
        }
        public void ExpandCollection()
        {
            ISelectExpandWrapper[] result = ClassWithCollection.CreateQuery().OData().SelectExpand("Name", "Link2").ToArray();

            IDictionary <string, object> metadata = result[0].ToDictionary();

            // Not expanded by default
            Assert.Equal(2, metadata.Count);
            Assert.Equal(2, (metadata["Link2"] as IEnumerable <ISelectExpandWrapper>).Count());
        }
        public void ExpandCollectionWithFilterAndSelect()
        {
            ISelectExpandWrapper[] result = ClassWithCollection.CreateQuery().OData().SelectExpand("Name", "Link2($filter=Id eq 311;$select=Name)").ToArray();

            IDictionary <string, object> metadata = result[0].ToDictionary();

            // Not expanded by default
            Assert.Equal(2, metadata.Count);
            IEnumerable <ISelectExpandWrapper> collection = metadata["Link2"] as IEnumerable <ISelectExpandWrapper>;

            Assert.Single(collection);

            Assert.Equal(1, collection.Single().ToDictionary().Count);
        }
Ejemplo n.º 6
0
        public void Test()
        {
            var c           = new ClassWithCollection();
            var countItem   = 0;
            var countCount  = 0;
            var countOthers = 0;

            if (c.Children is INotifyPropertyChanged p)
            {
                p.PropertyChanged += (s, a) =>
                {
                    switch (a.PropertyName)
                    {
                    case "Item":
                        countItem++;
                        break;

                    case "Count":
                        countCount++;
                        break;

                    default:
                        countOthers++;
                        break;
                    }
                };
            }

            var child1 = new ClassWithProperty {
                Value = 25
            };

            c.Children.Add(child1);
            var child2 = new ClassWithProperty {
                Value = 17
            };

            c.Children.Add(child2);

            Assert.Equal(c.Children.Sum(i => i.Value), c.Sum);
            Assert.Equal(0, countOthers);
            //Assert.Equal(2, countCount);
            //Assert.Equal(2,countItem);

            child1.Value = 8;
            child2.Value = 2;
            Assert.Equal(c.Children.Sum(i => i.Value), c.Sum);
        }
 public void Setup()
 {
     simpleClass = new SimpleClass()
     {
         Age = 62, Name = "Me"
     };
     classWithMember = new ClassWithMember()
     {
         SimpleClass = simpleClass, CreatedOn = DateTime.Now
     };
     classWithCollection = new ClassWithCollection()
     {
         Id = Guid.NewGuid(), SimpleClasses = new List <SimpleClass>(new[] { simpleClass })
     };
     decorationDefinition           = ModelDecorators.Init <ClassWithMember, Decorators>();
     decorationCollectionDefinition = ModelDecorators.Init <ClassWithCollection, Decorators>();
 }
Ejemplo n.º 8
0
 public void Setup()
 {
     simpleClass = new SimpleClass()
     {
         Age = 62, Name = "Me"
     };
     classWithMember          = new ClassWithMember();
     classWithCollection      = new ClassWithCollection();
     classWithDynamicProperty = new ClassWithDynamicProperty()
     {
         Id = Guid.NewGuid(), ADynamicPrioperty = new SimpleClass()
     };
     recursiveClassPrincipal = new RecursiveClassPrincipal()
     {
         DependantOn = new RecursiveClassDependant()
         {
             PrincipalFrom = new RecursiveClassPrincipal(), Number = 2
         },
         Count = 1
     };
 }
 public void ExpandCollectionWithTopExceedLimit()
 {
     Assert.Throws <ODataException>(
         () => ClassWithCollection.CreateQuery().OData().SelectExpand("Name", "Link2($top=101)"));
 }