public void ShouldNotAppendValueIfNull()
        {
            var emptyAddress = new Address()
            {
                City  = null,
                Line1 = "duong7,phuocbinh"
            };
            var expected = LuceneBuilder.Create().WhereEquals(() => emptyAddress.City).And().WhereEquals(() => emptyAddress.Line1).ToString();

            StringAssert.AreEqualIgnoringCase("Line1:\"duong7,phuocbinh\"", expected);
        }
Exemplo n.º 2
0
        public void LuceneSymbolSyntax()
        {
            var actual =
                LuceneBuilder.Create().WhereEquals(() => address.City)
                .And()
                .WhereEquals(() => address.Country)
                .Or()
                .WhereEquals(() => address.Line1)
                .ToString();

            StringAssert.AreEqualIgnoringCase("City:\"HCM\" AND Country:\"VietNam\" OR Line1:\"Phuoc binh\"", actual);
        }
Exemplo n.º 3
0
        public void PharaseAtBegin()
        {
            var actual = LuceneBuilder.Create()
                         .Pharase(builder => builder.WhereEquals(() => address.PostalCode).And().WhereEquals(() => Customer.FirstName))
                         .And()
                         .WhereEquals(() => address.Country)
                         .Or()
                         .WhereEquals(() => address.Line1)
                         .And()
                         .Pharase(a => a.WhereEquals(() => address.Line2).And().WhereEquals(() => address.PostalCode)).ToString();

            StringAssert.AreEqualIgnoringCase("(PostalCode:\"99999\" AND FirstName:\"Cuong\") AND Country:\"VietNam\" OR Line1:\"Phuoc binh\" AND (Line2:\"Quan9\" AND PostalCode:\"99999\")", actual);
        }
Exemplo n.º 4
0
        public void Pharase()
        {
            var actual = LuceneBuilder.Create()
                         .WhereEquals(() => address.City)
                         .And()
                         .WhereEquals(() => address.Country)
                         .Or()
                         .WhereEquals(() => address.Line1)
                         .And()
                         .Pharase(a => a.WhereEquals(() => address.Line2).And().WhereEquals(() => address.PostalCode)).ToString();

            StringAssert.AreEqualIgnoringCase("City:\"HCM\" AND Country:\"VietNam\" OR Line1:\"Phuoc binh\" AND (Line2:\"Quan9\" AND PostalCode:\"99999\")", actual);
        }
        public void ShouldNotAppendValueIfNullAndBeforeSymbolSyntax()
        {
            var emptyAddress = new Address()
            {
                PostalCode = "123",
                City       = null,
                Line1      = "duong7,phuocbinh"
            };
            var expected = LuceneBuilder.Create()
                           .WhereEquals(() => emptyAddress.PostalCode)
                           .Or()
                           .WhereEquals(() => emptyAddress.City)
                           .And()
                           .WhereEquals(() => emptyAddress.Line1).ToString();

            StringAssert.AreEqualIgnoringCase("PostalCode:\"123\" AND Line1:\"duong7,phuocbinh\"", expected);
        }
        public void RemoveSyntaxWhenPropertyNull()
        {
            var addressEmpty = new Address()
            {
                Country    = null,
                City       = String.Empty,
                PostalCode = String.Empty
            };
            var actual =
                LuceneBuilder.Create()
                .WhereEquals(() => addressEmpty.City)
                .And()
                .Pharase(
                    builder =>
                    builder.WhereEquals(() => addressEmpty.PostalCode).And().WhereEquals(() => addressEmpty.Region)).ToString();

            StringAssert.AreEqualIgnoringCase(String.Empty, actual);
        }
        public void RemoveValueInPharaseIfPropertiesIsEmpty()
        {
            var emptyAddress = new Address()
            {
                Line1      = null,
                Country    = "VietName",
                PostalCode = ""
            };
            var expected =
                LuceneBuilder.Create().Pharase(
                    builder =>
                    builder.WhereEquals(() => emptyAddress.Line1)
                    .And()
                    .WhereEquals(() => emptyAddress.Country)
                    .Or()
                    .WhereEquals(() => emptyAddress.PostalCode)).ToString();

            StringAssert.AreEqualIgnoringCase("(Country:\"VietName\")", expected);
        }
Exemplo n.º 8
0
        public void EqualsTest()
        {
            var actual = LuceneBuilder.Create().WhereEquals(() => address.City).ToString();

            StringAssert.AreEqualIgnoringCase("City:\"HCM\"", actual);
        }
Exemplo n.º 9
0
        public void RangeWithSomeSymbolsTest()
        {
            var actual = LuceneBuilder.Create().Range(() => address.StateCode, 1, 2).And().Not(() => address.Country).ToString();

            StringAssert.AreEqualIgnoringCase("StateCode:[1 TO 2] AND -Country:VietNam", actual);
        }
Exemplo n.º 10
0
        public void RangeTest()
        {
            var actual = LuceneBuilder.Create().Range(() => address.StateCode, 1, 2).ToString();

            StringAssert.AreEqualIgnoringCase("StateCode:[1 TO 2]", actual);
        }
Exemplo n.º 11
0
        public void NotTest()
        {
            var actual = LuceneBuilder.Create().Not(() => address.City).And().WhereEquals(() => address.Line1).ToString();

            StringAssert.AreEqualIgnoringCase("-City:HCM AND Line1:\"Phuoc binh\"", actual);
        }
Exemplo n.º 12
0
        public void EndWithTest()
        {
            var actual = LuceneBuilder.Create().EndWith(() => address.City).ToString();

            StringAssert.AreEqualIgnoringCase("City:*HCM", actual);
        }