public void Retrive() { ReCreateDatabaseForTesting(); var tasks = _fixture.Build <Task>().With(x => x.IsCompleted, true).CreateMany(); using (var context = new MusicStoreEntities()) { var handler = new TasksByStatusQueryHandler(new EntityRepository <Task>(context)); foreach (var task in tasks) { context.SetAsAdded <Task>(task); } context.SaveChanges(); var result = handler.Retrieve(new TasksByStatusQuery() { IsCompleted = true }); Assert.Equal(result.Tasks.Count(), 3); } }