|
1 | 1 | using System;
|
2 | 2 | using System.Linq;
|
3 | 3 | using System.Threading.Tasks;
|
| 4 | +using Marten; |
4 | 5 | using Marten.Testing.Documents;
|
5 | 6 | using Marten.Testing.Harness;
|
6 | 7 | using Shouldly;
|
@@ -70,6 +71,50 @@ public async Task query_against_null_3()
|
70 | 71 | .ShouldBe(1);
|
71 | 72 | }
|
72 | 73 |
|
| 74 | + [Fact] |
| 75 | + public async Task query_against_nullable_bool_not_true() |
| 76 | + { |
| 77 | + var target1 = new Target { NullableBoolean = null }; |
| 78 | + theSession.Store(target1); |
| 79 | + |
| 80 | + var target2 = new Target { NullableBoolean = true }; |
| 81 | + theSession.Store(target2); |
| 82 | + |
| 83 | + var target3 = new Target { NullableBoolean = false }; |
| 84 | + theSession.Store(target3); |
| 85 | + |
| 86 | + await theSession.SaveChangesAsync(); |
| 87 | + |
| 88 | + theSession.Logger = new TestOutputMartenLogger(_output); |
| 89 | + |
| 90 | + var list = await theSession.Query<Target>().Where(x => x.NullableBoolean != true).ToListAsync(); |
| 91 | + list.Count.ShouldBe(2); |
| 92 | + list.Any(x => x.Id == target1.Id).ShouldBeTrue(); |
| 93 | + list.Any(x => x.Id == target3.Id).ShouldBeTrue(); |
| 94 | + } |
| 95 | + |
| 96 | + [Fact] |
| 97 | + public async Task query_against_nullable_bool_not_false() |
| 98 | + { |
| 99 | + var target1 = new Target { NullableBoolean = null }; |
| 100 | + theSession.Store(target1); |
| 101 | + |
| 102 | + var target2 = new Target { NullableBoolean = true }; |
| 103 | + theSession.Store(target2); |
| 104 | + |
| 105 | + var target3 = new Target { NullableBoolean = false }; |
| 106 | + theSession.Store(target3); |
| 107 | + |
| 108 | + await theSession.SaveChangesAsync(); |
| 109 | + |
| 110 | + theSession.Logger = new TestOutputMartenLogger(_output); |
| 111 | + |
| 112 | + var list = await theSession.Query<Target>().Where(x => x.NullableBoolean != false).ToListAsync(); |
| 113 | + list.Count.ShouldBe(2); |
| 114 | + list.Any(x => x.Id == target1.Id).ShouldBeTrue(); |
| 115 | + list.Any(x => x.Id == target2.Id).ShouldBeTrue(); |
| 116 | + } |
| 117 | + |
73 | 118 | [Fact]
|
74 | 119 | public async Task query_against_null_4()
|
75 | 120 | {
|
|
0 commit comments