Beispiel #1
0
        public void AndOrTest()
        {
            Assert.Throws <NotImplementedException>(() => OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(x =>
                                                                                                                                    x.Email == "test" && (x.Name == "test" || x.Name == "info")));

            Assert.Throws <NotImplementedException>(() => OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(x =>
                                                                                                                                    x.Email == "test" && x.Name == "test" || x.Name == "info"));
        }
Beispiel #2
0
        public void SinglePropStringSearchTest()
        {
            var command = OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(
                x => x.Name == "test");

            Assert.IsNotNull(command);
            Assert.That(command.Arguments.Any());
            Assert.That(command.Arguments.Count == 1);
            Assert.That(command.Arguments.First().Operation == "=");
        }
Beispiel #3
0
        public void MultiOrTest()
        {
            var command = OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(x =>
                                                                                                    x.Name == "test" || x.Name == "info" || x.Name == "test2");

            Assert.IsNotNull(command);
            Assert.That(command.Arguments.Any());

            var args = command.GetArguments();

            Assert.That(args.Count() == 4);
        }
Beispiel #4
0
        public void SinglePropBoolFalseSearchTest()
        {
            var command = OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(x =>
                                                                                                    !x.IsCompany);

            Assert.IsNotNull(command);
            Assert.That(command.Arguments.Any());

            var param = command.GetArguments();

            Assert.That(param.Any());
            Assert.That(param.Count() == 1);

            var arg1 = (object[])param[0];

            Assert.That((string)arg1[1] == "=");
            Assert.That((bool)arg1[2] == false);
        }
Beispiel #5
0
        public void DoublePropAndStringSearchTest()
        {
            var command = OdooCommandContextFactory.BuildCommandContextFromExpression <OdooPartner>(
                x => x.Name == "test" && x.Email.Contains("@"));

            Assert.IsNotNull(command);
            Assert.That(command.Arguments.Any());

            var param = command.GetArguments();

            Assert.That(param.Any());
            Assert.That(param.Count() == 2);

            var arg1 = (object[])param[0];
            var arg2 = (object[])param[1];

            Assert.That((string)arg1[1] == "=");
            Assert.That((string)arg2[1] == "ilike");
        }
Beispiel #6
0
 internal IEnumerable <T> GetEntities <T>(Expression <Func <T, bool> > conditions, int?offset = null, int?limit = null, string order = null) where T : IOdooObject, new()
 {
     try
     {
         OdooCommandContext context;
         context        = OdooCommandContextFactory.BuildCommandContextFromExpression <T>(conditions);
         context.Limit  = limit ?? 0;
         context.Offset = offset ?? 0;
         context.Order  = order;
         IEnumerable <object> ids = SearchCommand(context);
         context.ClearArguments();
         ResultSet       result   = GetEntityCommand(context, ids);
         IEnumerable <T> entities = OdooObjectFactory.BuildEntities <T>(this, result);
         return(entities);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }