Exemple #1
0
        public void ParseNameValueCollectionNoExpandParamTest()
        {
            // Arrange
            var collection = new NameValueCollection();

            // Act
            var actual = new ExpandParser().Parse(collection);

            // Assert
            Assert.IsNull(actual);
        }
Exemple #2
0
        public void ParseCommaInParanthesisMissingCloseParanthesisTest()
        {
            // Arrange
            var paramValue = "Product($expand=ProductType,ProductGroupMembership($expand=ProductGroup,ProductFeatureMap)";
            var expected   = new List <ExpandPath>
            {
                new ExpandPath
                {
                    Entity      = "Product",
                    Parenthesis = "$expand=ProductType,ProductGroupMembership,ProductFeatureMap"
                }
            };
            var parser = new ExpandParser();

            // Act
            // Assert
            Assert.ThrowsException <ArgumentException>(() => { parser.Parse(paramValue); });
        }
Exemple #3
0
        public void ParseSubExpandPathAndParanthesisTest()
        {
            // Arrange
            var paramValue = "User($expand=Organization)";
            var expected   = new List <ExpandPath>
            {
                new ExpandPath
                {
                    Entity      = "User",
                    Parenthesis = "$expand=Organization"
                }
            };

            // Act
            var actual = new ExpandParser().Parse(paramValue);

            // Assert
            CollectionAssert.AreEqual(expected, actual, new ExpandPathComparer());
        }
Exemple #4
0
        public void ParseCommaInParanthesisDoubleNestedParanthesisTest()
        {
            // Arrange
            var paramValue = "Product($expand=ProductType,ProductGroupMembership($expand=ProductGroup),ProductFeatureMap)";
            var expected   = new List <ExpandPath>
            {
                new ExpandPath
                {
                    Entity      = "Product",
                    Parenthesis = "$expand=ProductType,ProductGroupMembership($expand=ProductGroup),ProductFeatureMap"
                }
            };

            // Act
            var actual = new ExpandParser().Parse(paramValue);

            // Assert
            CollectionAssert.AreEqual(expected, actual, new ExpandPathComparer());
        }
Exemple #5
0
        public void ParseTest()
        {
            // Arrange
            var paramValue = "User,Organization";
            var expected   = new List <ExpandPath>
            {
                new ExpandPath {
                    Entity = "User"
                },
                new ExpandPath {
                    Entity = "Organization"
                }
            };

            // Act
            var actual = new ExpandParser().Parse(paramValue);

            // Assert
            CollectionAssert.AreEqual(expected, actual, new ExpandPathComparer());
        }
Exemple #6
0
        public void ParseNameValueCollectionTest()
        {
            // Arrange
            var collection = new NameValueCollection {
                { "$filter", "Id = 1" },
                { "$expand", "User,Organization" }
            };
            var expected = new List <ExpandPath>
            {
                new ExpandPath {
                    Entity = "User"
                },
                new ExpandPath {
                    Entity = "Organization"
                }
            };

            // Act
            var actual = new ExpandParser().Parse(collection);

            // Assert
            CollectionAssert.AreEqual(expected, actual, new ExpandPathComparer());
        }
        /// <inheritdoc />
        public virtual List <RelatedEntityCollection> GetRelatedEntities(IEnumerable <TInterface> entities, NameValueCollection parameters)
        {
            var expandPaths = new ExpandParser().Parse(parameters);

            return(TaskRunner.RunSynchonously(GetRelatedEntitiesAsync, entities, expandPaths));
        }