Fix issue where sorting or filtering a collection fails on accesssing null members.

This commit is contained in:
Kevin Dost
2020-10-17 20:10:52 +02:00
parent d86e35f77c
commit 5c2ef3773e
4 changed files with 89 additions and 35 deletions

View File

@@ -31,7 +31,6 @@ namespace SieveUnitTests
LikeCount = 100,
IsDraft = true,
CategoryId = null,
TopComment = new Comment { Id = 0, Text = "A1" },
FeaturedComment = new Comment { Id = 4, Text = "A2" }
},
new Post() {
@@ -57,7 +56,7 @@ namespace SieveUnitTests
LikeCount = 3,
IsDraft = true,
CategoryId = 2,
TopComment = new Comment { Id = 1, Text = "D1" },
TopComment = new Comment { Id = 1 },
FeaturedComment = new Comment { Id = 7, Text = "D2" }
},
}.AsQueryable();
@@ -388,11 +387,10 @@ namespace SieveUnitTests
};
var result = _processor.Apply(model, _posts);
Assert.AreEqual(3, result.Count());
Assert.AreEqual(2, result.Count());
var posts = result.ToList();
Assert.IsTrue(posts[0].TopComment.Text.Contains("B"));
Assert.IsTrue(posts[1].TopComment.Text.Contains("C"));
Assert.IsTrue(posts[2].TopComment.Text.Contains("D"));
}
[TestMethod]