public void List_Return_ShouldNotBeNull( int?start, int?end, bool archived) { // Arrange var context = GenerateContext("ListErros"); var service = new ErrorService(context); var expected = context.Errors .Where(x => x.IsArchived == archived) .Skip(start.HasValue ? start.Value : 0) .ToList(); // Act if (end.HasValue) { expected = expected .Take(end.Value) .ToList(); } var result = service.List( start, end, archived); // Assert Assert.NotNull(result); Assert.Equal(result.Count(), expected.Count()); }