|
| 1 | +/* Copyright 2010-present MongoDB Inc. |
| 2 | +* |
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +* you may not use this file except in compliance with the License. |
| 5 | +* You may obtain a copy of the License at |
| 6 | +* |
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +* |
| 9 | +* Unless required by applicable law or agreed to in writing, software |
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +* See the License for the specific language governing permissions and |
| 13 | +* limitations under the License. |
| 14 | +*/ |
| 15 | + |
| 16 | +using System.Collections.Generic; |
| 17 | +using System.Linq; |
| 18 | +using MongoDB.Driver.TestHelpers; |
| 19 | +using FluentAssertions; |
| 20 | +using Xunit; |
| 21 | + |
| 22 | +namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Jira; |
| 23 | + |
| 24 | +public class CSharp4535Tests : LinqIntegrationTest<CSharp4535Tests.ClassFixture> |
| 25 | +{ |
| 26 | + public CSharp4535Tests(ClassFixture fixture) |
| 27 | + : base(fixture) |
| 28 | + { |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void Empty_query_should_work() |
| 33 | + { |
| 34 | + var mongoEntityCollection = Fixture.Collection; |
| 35 | + var entityQueryable = (IQueryable<Entity>)mongoEntityCollection.AsQueryable(); |
| 36 | + |
| 37 | + var results = entityQueryable.ToArray(); |
| 38 | + |
| 39 | + results.Select(x => x.Id).Should().Equal(1); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + public void Where_should_work() |
| 44 | + { |
| 45 | + var mongoEntityCollection = Fixture.Collection; |
| 46 | + var entityQueryable = (IQueryable<Entity>)mongoEntityCollection.AsQueryable(); |
| 47 | + |
| 48 | + var queryable = entityQueryable.Where(x => x.Id == 1); |
| 49 | + |
| 50 | + var results = queryable.ToArray(); |
| 51 | + |
| 52 | + results.Select(x => x.Id).Should().Equal(1); |
| 53 | + } |
| 54 | + |
| 55 | + public class Entity |
| 56 | + { |
| 57 | + public int Id { get; set; } |
| 58 | + } |
| 59 | + |
| 60 | + public class MongoEntity : Entity |
| 61 | + { |
| 62 | + } |
| 63 | + |
| 64 | + public sealed class ClassFixture : MongoCollectionFixture<MongoEntity> |
| 65 | + { |
| 66 | + protected override IEnumerable<MongoEntity> InitialData => |
| 67 | + [ |
| 68 | + new MongoEntity { Id = 1 } |
| 69 | + ]; |
| 70 | + } |
| 71 | +} |
0 commit comments