|
22 | 22 | using MongoDB.Bson.Serialization.Attributes; |
23 | 23 | using MongoDB.Driver; |
24 | 24 | using MongoDB.Driver.Builders; |
| 25 | +using MongoDB.Driver.Core.TestHelpers.XunitExtensions; |
25 | 26 | using MongoDB.Driver.Linq; |
26 | 27 | using Xunit; |
27 | 28 |
|
@@ -4474,30 +4475,29 @@ where c.SA[0].Contains("o") |
4474 | 4475 | } |
4475 | 4476 | } |
4476 | 4477 |
|
4477 | | - [Fact] |
| 4478 | + [SkippableFact] |
4478 | 4479 | public void TestWhereSASub0ContainsONot() |
4479 | 4480 | { |
4480 | | - if (__server.BuildInfo.Version >= new Version(1, 8, 0)) |
4481 | | - { |
4482 | | - var query = from c in __collection.AsQueryable<C>() |
4483 | | - where !c.SA[0].Contains("o") |
4484 | | - select c; |
| 4481 | + RequireServer.Check().VersionGreaterThanOrEqualTo("1.8.0").VersionLessThan("5.0.0-"); |
4485 | 4482 |
|
4486 | | - var translatedQuery = MongoQueryTranslator.Translate(query); |
4487 | | - Assert.IsType<SelectQuery>(translatedQuery); |
4488 | | - Assert.Same(__collection, translatedQuery.Collection); |
4489 | | - Assert.Same(typeof(C), translatedQuery.DocumentType); |
| 4483 | + var query = from c in __collection.AsQueryable<C>() |
| 4484 | + where !c.SA[0].Contains("o") |
| 4485 | + select c; |
4490 | 4486 |
|
4491 | | - var selectQuery = (SelectQuery)translatedQuery; |
4492 | | - Assert.Equal("(C c) => !c.SA[0].Contains(\"o\")", ExpressionFormatter.ToString(selectQuery.Where)); |
4493 | | - Assert.Null(selectQuery.OrderBy); |
4494 | | - Assert.Null(selectQuery.Projection); |
4495 | | - Assert.Null(selectQuery.Skip); |
4496 | | - Assert.Null(selectQuery.Take); |
| 4487 | + var translatedQuery = MongoQueryTranslator.Translate(query); |
| 4488 | + Assert.IsType<SelectQuery>(translatedQuery); |
| 4489 | + Assert.Same(__collection, translatedQuery.Collection); |
| 4490 | + Assert.Same(typeof(C), translatedQuery.DocumentType); |
4497 | 4491 |
|
4498 | | - Assert.Equal("{ \"sa.0\" : { \"$not\" : /o/s } }", selectQuery.BuildQuery().ToJson()); |
4499 | | - Assert.Equal(4, Consume(query)); |
4500 | | - } |
| 4492 | + var selectQuery = (SelectQuery)translatedQuery; |
| 4493 | + Assert.Equal("(C c) => !c.SA[0].Contains(\"o\")", ExpressionFormatter.ToString(selectQuery.Where)); |
| 4494 | + Assert.Null(selectQuery.OrderBy); |
| 4495 | + Assert.Null(selectQuery.Projection); |
| 4496 | + Assert.Null(selectQuery.Skip); |
| 4497 | + Assert.Null(selectQuery.Take); |
| 4498 | + |
| 4499 | + Assert.Equal("{ \"sa.0\" : { \"$not\" : /o/s } }", selectQuery.BuildQuery().ToJson()); |
| 4500 | + Assert.Equal(4, Consume(query)); |
4501 | 4501 | } |
4502 | 4502 |
|
4503 | 4503 | [Fact] |
@@ -4526,30 +4526,29 @@ where c.SA[0].EndsWith("m") |
4526 | 4526 | } |
4527 | 4527 | } |
4528 | 4528 |
|
4529 | | - [Fact] |
| 4529 | + [SkippableFact] |
4530 | 4530 | public void TestWhereSASub0EndsWithMNot() |
4531 | 4531 | { |
4532 | | - if (__server.BuildInfo.Version >= new Version(1, 8, 0)) |
4533 | | - { |
4534 | | - var query = from c in __collection.AsQueryable<C>() |
4535 | | - where !c.SA[0].EndsWith("m") |
4536 | | - select c; |
| 4532 | + RequireServer.Check().VersionGreaterThanOrEqualTo("1.8.0").VersionLessThan("5.0.0-"); |
4537 | 4533 |
|
4538 | | - var translatedQuery = MongoQueryTranslator.Translate(query); |
4539 | | - Assert.IsType<SelectQuery>(translatedQuery); |
4540 | | - Assert.Same(__collection, translatedQuery.Collection); |
4541 | | - Assert.Same(typeof(C), translatedQuery.DocumentType); |
| 4534 | + var query = from c in __collection.AsQueryable<C>() |
| 4535 | + where !c.SA[0].EndsWith("m") |
| 4536 | + select c; |
4542 | 4537 |
|
4543 | | - var selectQuery = (SelectQuery)translatedQuery; |
4544 | | - Assert.Equal("(C c) => !c.SA[0].EndsWith(\"m\")", ExpressionFormatter.ToString(selectQuery.Where)); |
4545 | | - Assert.Null(selectQuery.OrderBy); |
4546 | | - Assert.Null(selectQuery.Projection); |
4547 | | - Assert.Null(selectQuery.Skip); |
4548 | | - Assert.Null(selectQuery.Take); |
| 4538 | + var translatedQuery = MongoQueryTranslator.Translate(query); |
| 4539 | + Assert.IsType<SelectQuery>(translatedQuery); |
| 4540 | + Assert.Same(__collection, translatedQuery.Collection); |
| 4541 | + Assert.Same(typeof(C), translatedQuery.DocumentType); |
4549 | 4542 |
|
4550 | | - Assert.Equal("{ \"sa.0\" : { \"$not\" : /m$/s } }", selectQuery.BuildQuery().ToJson()); |
4551 | | - Assert.Equal(4, Consume(query)); |
4552 | | - } |
| 4543 | + var selectQuery = (SelectQuery)translatedQuery; |
| 4544 | + Assert.Equal("(C c) => !c.SA[0].EndsWith(\"m\")", ExpressionFormatter.ToString(selectQuery.Where)); |
| 4545 | + Assert.Null(selectQuery.OrderBy); |
| 4546 | + Assert.Null(selectQuery.Projection); |
| 4547 | + Assert.Null(selectQuery.Skip); |
| 4548 | + Assert.Null(selectQuery.Take); |
| 4549 | + |
| 4550 | + Assert.Equal("{ \"sa.0\" : { \"$not\" : /m$/s } }", selectQuery.BuildQuery().ToJson()); |
| 4551 | + Assert.Equal(4, Consume(query)); |
4553 | 4552 | } |
4554 | 4553 |
|
4555 | 4554 | [Fact] |
@@ -4579,31 +4578,30 @@ where regex.IsMatch(c.SA[0]) |
4579 | 4578 | } |
4580 | 4579 | } |
4581 | 4580 |
|
4582 | | - [Fact] |
| 4581 | + [SkippableFact] |
4583 | 4582 | public void TestWhereSASub0IsMatchNot() |
4584 | 4583 | { |
4585 | | - if (__server.BuildInfo.Version >= new Version(1, 8, 0)) |
4586 | | - { |
4587 | | - var regex = new Regex(@"^T"); |
4588 | | - var query = from c in __collection.AsQueryable<C>() |
4589 | | - where !regex.IsMatch(c.SA[0]) |
4590 | | - select c; |
| 4584 | + RequireServer.Check().VersionGreaterThanOrEqualTo("1.8.0").VersionLessThan("5.0.0-"); |
4591 | 4585 |
|
4592 | | - var translatedQuery = MongoQueryTranslator.Translate(query); |
4593 | | - Assert.IsType<SelectQuery>(translatedQuery); |
4594 | | - Assert.Same(__collection, translatedQuery.Collection); |
4595 | | - Assert.Same(typeof(C), translatedQuery.DocumentType); |
| 4586 | + var regex = new Regex(@"^T"); |
| 4587 | + var query = from c in __collection.AsQueryable<C>() |
| 4588 | + where !regex.IsMatch(c.SA[0]) |
| 4589 | + select c; |
4596 | 4590 |
|
4597 | | - var selectQuery = (SelectQuery)translatedQuery; |
4598 | | - Assert.Equal("(C c) => !Regex:(@\"^T\").IsMatch(c.SA[0])", ExpressionFormatter.ToString(selectQuery.Where)); |
4599 | | - Assert.Null(selectQuery.OrderBy); |
4600 | | - Assert.Null(selectQuery.Projection); |
4601 | | - Assert.Null(selectQuery.Skip); |
4602 | | - Assert.Null(selectQuery.Take); |
| 4591 | + var translatedQuery = MongoQueryTranslator.Translate(query); |
| 4592 | + Assert.IsType<SelectQuery>(translatedQuery); |
| 4593 | + Assert.Same(__collection, translatedQuery.Collection); |
| 4594 | + Assert.Same(typeof(C), translatedQuery.DocumentType); |
4603 | 4595 |
|
4604 | | - Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/ } }", selectQuery.BuildQuery().ToJson()); |
4605 | | - Assert.Equal(4, Consume(query)); |
4606 | | - } |
| 4596 | + var selectQuery = (SelectQuery)translatedQuery; |
| 4597 | + Assert.Equal("(C c) => !Regex:(@\"^T\").IsMatch(c.SA[0])", ExpressionFormatter.ToString(selectQuery.Where)); |
| 4598 | + Assert.Null(selectQuery.OrderBy); |
| 4599 | + Assert.Null(selectQuery.Projection); |
| 4600 | + Assert.Null(selectQuery.Skip); |
| 4601 | + Assert.Null(selectQuery.Take); |
| 4602 | + |
| 4603 | + Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/ } }", selectQuery.BuildQuery().ToJson()); |
| 4604 | + Assert.Equal(4, Consume(query)); |
4607 | 4605 | } |
4608 | 4606 |
|
4609 | 4607 | [Fact] |
@@ -4632,30 +4630,29 @@ where Regex.IsMatch(c.SA[0], "^T") |
4632 | 4630 | } |
4633 | 4631 | } |
4634 | 4632 |
|
4635 | | - [Fact] |
| 4633 | + [SkippableFact] |
4636 | 4634 | public void TestWhereSASub0IsMatchStaticNot() |
4637 | 4635 | { |
4638 | | - if (__server.BuildInfo.Version >= new Version(1, 8, 0)) |
4639 | | - { |
4640 | | - var query = from c in __collection.AsQueryable<C>() |
4641 | | - where !Regex.IsMatch(c.SA[0], "^T") |
4642 | | - select c; |
| 4636 | + RequireServer.Check().VersionGreaterThanOrEqualTo("1.8.0").VersionLessThan("5.0.0-"); |
4643 | 4637 |
|
4644 | | - var translatedQuery = MongoQueryTranslator.Translate(query); |
4645 | | - Assert.IsType<SelectQuery>(translatedQuery); |
4646 | | - Assert.Same(__collection, translatedQuery.Collection); |
4647 | | - Assert.Same(typeof(C), translatedQuery.DocumentType); |
| 4638 | + var query = from c in __collection.AsQueryable<C>() |
| 4639 | + where !Regex.IsMatch(c.SA[0], "^T") |
| 4640 | + select c; |
4648 | 4641 |
|
4649 | | - var selectQuery = (SelectQuery)translatedQuery; |
4650 | | - Assert.Equal("(C c) => !Regex.IsMatch(c.SA[0], \"^T\")", ExpressionFormatter.ToString(selectQuery.Where)); |
4651 | | - Assert.Null(selectQuery.OrderBy); |
4652 | | - Assert.Null(selectQuery.Projection); |
4653 | | - Assert.Null(selectQuery.Skip); |
4654 | | - Assert.Null(selectQuery.Take); |
| 4642 | + var translatedQuery = MongoQueryTranslator.Translate(query); |
| 4643 | + Assert.IsType<SelectQuery>(translatedQuery); |
| 4644 | + Assert.Same(__collection, translatedQuery.Collection); |
| 4645 | + Assert.Same(typeof(C), translatedQuery.DocumentType); |
4655 | 4646 |
|
4656 | | - Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/ } }", selectQuery.BuildQuery().ToJson()); |
4657 | | - Assert.Equal(4, Consume(query)); |
4658 | | - } |
| 4647 | + var selectQuery = (SelectQuery)translatedQuery; |
| 4648 | + Assert.Equal("(C c) => !Regex.IsMatch(c.SA[0], \"^T\")", ExpressionFormatter.ToString(selectQuery.Where)); |
| 4649 | + Assert.Null(selectQuery.OrderBy); |
| 4650 | + Assert.Null(selectQuery.Projection); |
| 4651 | + Assert.Null(selectQuery.Skip); |
| 4652 | + Assert.Null(selectQuery.Take); |
| 4653 | + |
| 4654 | + Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/ } }", selectQuery.BuildQuery().ToJson()); |
| 4655 | + Assert.Equal(4, Consume(query)); |
4659 | 4656 | } |
4660 | 4657 |
|
4661 | 4658 | [Fact] |
@@ -4710,30 +4707,29 @@ where c.SA[0].StartsWith("T") |
4710 | 4707 | } |
4711 | 4708 | } |
4712 | 4709 |
|
4713 | | - [Fact] |
| 4710 | + [SkippableFact] |
4714 | 4711 | public void TestWhereSASub0StartsWithTNot() |
4715 | 4712 | { |
4716 | | - if (__server.BuildInfo.Version >= new Version(1, 8, 0)) |
4717 | | - { |
4718 | | - var query = from c in __collection.AsQueryable<C>() |
4719 | | - where !c.SA[0].StartsWith("T") |
4720 | | - select c; |
| 4713 | + RequireServer.Check().VersionGreaterThanOrEqualTo("1.8.0").VersionLessThan("5.0.0-"); |
4721 | 4714 |
|
4722 | | - var translatedQuery = MongoQueryTranslator.Translate(query); |
4723 | | - Assert.IsType<SelectQuery>(translatedQuery); |
4724 | | - Assert.Same(__collection, translatedQuery.Collection); |
4725 | | - Assert.Same(typeof(C), translatedQuery.DocumentType); |
| 4715 | + var query = from c in __collection.AsQueryable<C>() |
| 4716 | + where !c.SA[0].StartsWith("T") |
| 4717 | + select c; |
4726 | 4718 |
|
4727 | | - var selectQuery = (SelectQuery)translatedQuery; |
4728 | | - Assert.Equal("(C c) => !c.SA[0].StartsWith(\"T\")", ExpressionFormatter.ToString(selectQuery.Where)); |
4729 | | - Assert.Null(selectQuery.OrderBy); |
4730 | | - Assert.Null(selectQuery.Projection); |
4731 | | - Assert.Null(selectQuery.Skip); |
4732 | | - Assert.Null(selectQuery.Take); |
| 4719 | + var translatedQuery = MongoQueryTranslator.Translate(query); |
| 4720 | + Assert.IsType<SelectQuery>(translatedQuery); |
| 4721 | + Assert.Same(__collection, translatedQuery.Collection); |
| 4722 | + Assert.Same(typeof(C), translatedQuery.DocumentType); |
4733 | 4723 |
|
4734 | | - Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/s } }", selectQuery.BuildQuery().ToJson()); |
4735 | | - Assert.Equal(4, Consume(query)); |
4736 | | - } |
| 4724 | + var selectQuery = (SelectQuery)translatedQuery; |
| 4725 | + Assert.Equal("(C c) => !c.SA[0].StartsWith(\"T\")", ExpressionFormatter.ToString(selectQuery.Where)); |
| 4726 | + Assert.Null(selectQuery.OrderBy); |
| 4727 | + Assert.Null(selectQuery.Projection); |
| 4728 | + Assert.Null(selectQuery.Skip); |
| 4729 | + Assert.Null(selectQuery.Take); |
| 4730 | + |
| 4731 | + Assert.Equal("{ \"sa.0\" : { \"$not\" : /^T/s } }", selectQuery.BuildQuery().ToJson()); |
| 4732 | + Assert.Equal(4, Consume(query)); |
4737 | 4733 | } |
4738 | 4734 |
|
4739 | 4735 | [Fact] |
|
0 commit comments