/// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary <string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.ComplexCast)
            {
                ComplexCastPathSegment castSegment = (ComplexCastPathSegment)pathSegment;
                return(castSegment.CastType == CastType && castSegment.CastTypeName == CastTypeName);
            }

            return(false);
        }
        public void GetNavigationSource_Returns_PreviousEntitySet()
        {
            // Arrange
            EdmComplexType castType = new EdmComplexType("NS", "Complex");
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);
            IEdmNavigationSource previousNavigationSource = new Mock<IEdmNavigationSource>().Object;

            // Act
            var result = castSegment.GetNavigationSource(previousNavigationSource);

            // Assert
            Assert.Same(previousNavigationSource, result);
        }
        public void GetEdmType_ReturnsCastType_IfPreviousTypeIsNotCollection()
        {
            // Arrange
            EdmComplexType castType = new EdmComplexType("NS", "Complex");
            EdmComplexType previousEdmType = new EdmComplexType("NS", "PreviousType");
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);

            // Act
            var result = castSegment.GetEdmType(previousEdmType);

            // Assert
            Assert.Equal(castType, result);
        }
Пример #4
0
        public void GetNavigationSource_Returns_PreviousEntitySet()
        {
            // Arrange
            EdmComplexType         castType    = new EdmComplexType("NS", "Complex");
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);
            IEdmNavigationSource   previousNavigationSource = new Mock <IEdmNavigationSource>().Object;

            // Act
            var result = castSegment.GetNavigationSource(previousNavigationSource);

            // Assert
            Assert.Same(previousNavigationSource, result);
        }
Пример #5
0
        public void GetEdmType_ReturnsCastType_IfPreviousTypeIsNotCollection()
        {
            // Arrange
            EdmComplexType         castType        = new EdmComplexType("NS", "Complex");
            EdmComplexType         previousEdmType = new EdmComplexType("NS", "PreviousType");
            ComplexCastPathSegment castSegment     = new ComplexCastPathSegment(castType);

            // Act
            var result = castSegment.GetEdmType(previousEdmType);

            // Assert
            Assert.Equal(castType, result);
        }
        public void TryMatch_ReturnsTrue_IfCastTypeMatch()
        {
            // Arrange
            EdmComplexType castType = new EdmComplexType("NS", "Complex");
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);
            ComplexCastPathSegment pathSegment = new ComplexCastPathSegment(castType);
            Dictionary<string, object> values = new Dictionary<string, object>();

            // Act
            var result = castSegment.TryMatch(pathSegment, values);

            // Assert
            Assert.True(result);
            Assert.Empty(values);
        }
        public void GetEdmType_ReturnsCollectionCastType_IfPreviousTypeIsCollection()
        {
            // Arrange
            EdmComplexType castType = new EdmComplexType("NS", "Complex");
            EdmCollectionType previousEdmType =
                new EdmCollectionType(new EdmComplexType("NS", "PreviousType").AsReference());
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);

            // Act
            var result = castSegment.GetEdmType(previousEdmType);

            // Assert
            Assert.Equal(EdmTypeKind.Collection, result.TypeKind);
            Assert.Equal(castType, (result as IEdmCollectionType).ElementType.Definition);
        }
Пример #8
0
        public void TryMatch_ReturnsTrue_IfCastTypeMatch()
        {
            // Arrange
            EdmComplexType              castType    = new EdmComplexType("NS", "Complex");
            ComplexCastPathSegment      castSegment = new ComplexCastPathSegment(castType);
            ComplexCastPathSegment      pathSegment = new ComplexCastPathSegment(castType);
            Dictionary <string, object> values      = new Dictionary <string, object>();

            // Act
            var result = castSegment.TryMatch(pathSegment, values);

            // Assert
            Assert.True(result);
            Assert.Empty(values);
        }
Пример #9
0
        public void GetEdmType_ReturnsCollectionCastType_IfPreviousTypeIsCollection()
        {
            // Arrange
            EdmComplexType    castType        = new EdmComplexType("NS", "Complex");
            EdmCollectionType previousEdmType =
                new EdmCollectionType(new EdmComplexType("NS", "PreviousType").AsReference());
            ComplexCastPathSegment castSegment = new ComplexCastPathSegment(castType);

            // Act
            var result = castSegment.GetEdmType(previousEdmType);

            // Assert
            Assert.Equal(EdmTypeKind.Collection, result.TypeKind);
            Assert.Equal(castType, (result as IEdmCollectionType).ElementType.Definition);
        }