public void FilterWithEnum_ToString()
    {
        Expression <Func <TestEntity, bool> > filter = x => x.Address.Type.ToString() == AddressType.Corporate.ToString();

        Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}",
                     ODataExpression.FromLinqExpression(filter).AsString(_session));
    }
Exemple #2
0
        public void FilterWithEnum_HasFlag()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type.HasFlag(AddressType.Corporate);

            Assert.Equal(string.Format("Address/Type has {0}", FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")),
                         ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void FilterWithEnum_HasFlag()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type.HasFlag(AddressType.Corporate);

            Assert.Equal($"Address/Type has {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), typeof(AddressType).Namespace)}",
                         ODataExpression.FromLinqExpression(filter).AsString(Session));
        }
        public void FilterWithEnum()
        {
            var x      = ODataDynamic.Expression;
            var filter = x.Address.Type == AddressType.Corporate;

            Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", filter.AsString(_session));
        }
Exemple #5
0
        public void FilterWithEnum_Const()
        {
            const AddressType addressType = AddressType.Corporate;
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type == addressType;

            Assert.Equal(string.Format("Address/Type eq {0}", FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")),
                         ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void FilterWithEnum_Const()
        {
            const AddressType addressType = AddressType.Corporate;
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type == addressType;

            Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), typeof(AddressType).Namespace)}",
                         ODataExpression.FromLinqExpression(filter).AsString(Session));
        }
        public void FilterWithEnum()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type == AddressType.Corporate;
            var result   = ODataExpression.FromLinqExpression(filter).AsString(Session);
            var expected = $"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), typeof(AddressType).Namespace)}";

            Assert.Equal(expected, result);
        }
Exemple #8
0
        public void FilterWithEnum_Const()
        {
            var x = ODataDynamic.Expression;
            const AddressType addressType = AddressType.Corporate;
            var filter = x.Address.Type == addressType;

            Assert.Equal(string.Format("Address/Type eq {0}", FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")),
                         filter.AsString(_session));
        }
    public void FilterWithEnum_PrefixFree()
    {
        var enumPrefixFree = _session.Settings.EnumPrefixFree;

        _session.Settings.EnumPrefixFree = true;
        try
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Address.Type == AddressType.Corporate;
            Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel", true)}",
                         ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        finally
        {
            _session.Settings.EnumPrefixFree = enumPrefixFree;
        }
    }
        public void FilterWithEnum_PrefixFree()
        {
            var enumPrefixFree = Session.EnumPrefixFree;

            Session = new Session(true);
            try
            {
                Expression <Func <TestEntity, bool> > filter = x => x.Address.Type == AddressType.Corporate;
                var actual     = ODataExpression.FromLinqExpression(filter).AsString(Session);
                var enumFormat = FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), typeof(AddressType).Namespace, true);
                var expected   = $"Address/Type eq {enumFormat}";
                Assert.Equal(expected, actual);
            }
            finally
            {
                Session = new Session(enumPrefixFree);
            }
        }