public void ShouldExpectException_WhenConvertedExpressionHasWrongFieldName()
        {
            const string originalExpression =
                "Id eq 456 and Tags/any(t: t eq 'Dummy') and Details/Description eq 'Desc'";

            var fakeFieldMapper = new StubIFieldMapper()
            {
                MapStringStringString = (productPropertyName, propertyParentName, root) =>
                {
                    if (productPropertyName == "Id")
                    {
                        return("Id");
                    }
                    if (productPropertyName == "Tags" && string.IsNullOrEmpty(propertyParentName))
                    {
                        return("Tags");
                    }
                    if (productPropertyName == "Description" && propertyParentName == "Details")
                    {
                        return("DetailsDescription");
                    }
                    return("");
                }
            };
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _odataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), fakeFieldMapper);
            var convertedExpression = _odataConverter.Convert(originalExpression);
        }
        public ODataConverterTests()
        {
            _fieldMapper = new ProductFieldMapper();
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _odataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), _fieldMapper);
        }
示例#3
0
        public ProductsController()
        {
            _queryService = new InMemoryProductsQueryService();

            var fieldMapper         = new ProductFieldMapper();
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _oDataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), fieldMapper);
        }
示例#4
0
 public ProductsController(InMemoryProductsQueryService queryService, IODataExpressionConverter oDataConverter)
 {
     _queryService   = queryService;
     _oDataConverter = oDataConverter;
 }