public void test_THAT_daterangesoverlap_expression_with_special_constant_IS_valid()
        {
            var analyzer = new DateRangesOverlapAnalyzer(null, null);
            Expression <Func <SPListItem, bool> > expr = x => Camlex.DateRangesOverlap(x["start"], x["stop"], x["recurrence"], (DataTypes.DateTime)Camlex.Month);

            Assert.That(analyzer.IsValid(expr), Is.True);
        }
        public void test_THAT_daterangesoverlap_expression_with_string_variable_IS_valid()
        {
            var          analyzer = new DateRangesOverlapAnalyzer(null, null);
            const string now      = "02.01.2010 03:04:05";
            Expression <Func <SPListItem, bool> > expr = x => Camlex.DateRangesOverlap(x["start"], x["stop"], x["recurrence"], ((DataTypes.DateTime)now));

            Assert.That(analyzer.IsValid(expr), Is.True);
        }
        public void test_THAT_daterangesoverlap_expression_with_native_variable_IS_valid()
        {
            var analyzer = new DateRangesOverlapAnalyzer(null, null);
            var now      = DateTime.Now;
            Expression <Func <SPListItem, bool> > expr = x => Camlex.DateRangesOverlap(x["start"], x["stop"], x["recurrence"], now);

            Assert.That(analyzer.IsValid(expr), Is.True);
        }
Esempio n. 4
0
        // Scenario 9. Query with DateRangesOverlap
        // Lets suppose that you need to retrieve items which are recurrent events and their periods overlap specified one
        // <Query>
        //   <Where>
        //     <DateRangesOverlap>
        //       <FieldRef Name="StartField" />
        //       <FieldRef Name="StopField" />
        //       <FieldRef Name="RecurrenceID" />
        //       <Value Type="DateTime"><Month /></Value>
        //     </DateRangesOverlap>
        //   </Where>
        // </Query>
        public static void Scenario9()
        {
            var caml =
                Camlex.Query()
                .Where(x => Camlex.DateRangesOverlap(
                           x["StartField"], x["StopField"], x["RecurrenceID"], (DataTypes.DateTime)Camlex.Month)).ToString();

            Console.WriteLine(caml);
        }
        public void test_THAT_daterangesoverlap_expression_IS_determined_properly()
        {
            // arrange
            Expression <Func <SPListItem, bool> > expr = x => Camlex.DateRangesOverlap(x["start"], x["stop"], x["recurrence"], DateTime.Now);

            var operandBuilder = MockRepository.GenerateStub <IOperandBuilder>();

            operandBuilder.Stub(b => b.CreateFieldRefOperand(expr.Body, null)).Return(null);
            operandBuilder.Stub(b => b.CreateValueOperandForNativeSyntax(expr.Body)).Return(null);

            var analyzer = new DateRangesOverlapAnalyzer(null, operandBuilder);

            // act
            var operation = analyzer.GetOperation(expr);

            //assert
            Assert.That(operation, Is.InstanceOf <DateRangesOverlapOperation>());
        }
Esempio n. 6
0
        public void test_THAT_data_ranges_overlap_expression_with_string_contants_IS_translated_sucessfully()
        {
            var caml = Camlex.Query().Where(x => Camlex.DateRangesOverlap(
                                                x["StartField"], x["StopField"], x["RecurrenceID"], (DataTypes.DateTime)Camlex.Month)).ToString();

            var expected =
//                "<Query>" +
                "  <Where>" +
                "    <DateRangesOverlap>" +
                "      <FieldRef Name=\"StartField\" />" +
                "      <FieldRef Name=\"StopField\" />" +
                "      <FieldRef Name=\"RecurrenceID\" />" +
                "      <Value Type=\"DateTime\"><Month /></Value>" +
                "    </DateRangesOverlap>" +
                "  </Where>";

//                "</Query>";

            Assert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
        }
Esempio n. 7
0
        public void test_THAT_data_ranges_overlap_expression_with_string_syntax_IS_translated_sucessfully()
        {
            var now  = "2010-01-19 23:44:00";
            var caml = Camlex.Query().Where(x => Camlex.DateRangesOverlap(
                                                x["StartField"], x["StopField"], x["RecurrenceID"], (DataTypes.DateTime)now)).ToString();

            var expected =
//                "<Query>" +
                "  <Where>" +
                "    <DateRangesOverlap>" +
                "      <FieldRef Name=\"StartField\" />" +
                "      <FieldRef Name=\"StopField\" />" +
                "      <FieldRef Name=\"RecurrenceID\" />" +
                "      <Value Type=\"DateTime\">" + DateTime.Parse(now).ToString("s") + "Z</Value>" +
                "    </DateRangesOverlap>" +
                "  </Where>";

//                "</Query>";

            Assert.That(caml, Is.EqualTo(expected).Using(new CamlComparer()));
        }