forked from JasperFx/marten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix JasperFxGH-1374 - Fix JasperFxGH-1374 - Add unit tests * Fix related failing unit test
- Loading branch information
1 parent
f81e4c1
commit 6235a66
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Linq; | ||
using Marten.Services; | ||
using Xunit; | ||
|
||
namespace Marten.Testing.Linq | ||
{ | ||
public class BoolNotVisitorTests : DocumentSessionFixture<NulloIdentityMap> | ||
{ | ||
private class TestClass | ||
{ | ||
public TestClass() | ||
{ | ||
Id = Guid.NewGuid(); | ||
} | ||
|
||
public Guid Id { get; set; } | ||
public bool Flag { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void when_doc_with_bool_false_should_return_records() | ||
{ | ||
var docWithFlagFalse = new TestClass(); | ||
|
||
theSession.Store(docWithFlagFalse); | ||
theSession.SaveChanges(); | ||
|
||
using (var s = theStore.OpenSession()) | ||
{ | ||
var items = s.Query<TestClass>().Where(x => !x.Flag).ToList(); | ||
|
||
Assert.Single(items); | ||
Assert.Equal(docWithFlagFalse.Id, items[0].Id); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void when_doc_with_bool_false_with_serializer_default_value_handling_null_should_return_records() | ||
{ | ||
var serializer = new JsonNetSerializer(); | ||
serializer.Customize(s => | ||
{ | ||
s.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore; | ||
}); | ||
|
||
StoreOptions(x => x.Serializer(serializer)); | ||
|
||
// Note: with serializer settings DefaultValueHandling.Ignore, serialized JSON won't have Flag property | ||
var docWithFlagFalse = new TestClass(); | ||
|
||
theSession.Store(docWithFlagFalse); | ||
theSession.SaveChanges(); | ||
|
||
using (var s = theStore.OpenSession()) | ||
{ | ||
var items = s.Query<TestClass>().Where(x => !x.Flag).ToList(); | ||
|
||
Assert.Single(items); | ||
Assert.Equal(docWithFlagFalse.Id, items[0].Id); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters