public void TestAutomaticInvertedStartListCreation() { // Setup var lastRunStatuses = new[] { RunStatus.Completed, RunStatus.Disqualified, RunStatus.Completed }; IEnumerable <Run> newRunsAdded = null; var raceDaoMock = new Mock <IRaceDao>(); var runDaoMock = new Mock <IRunDao>(); runDaoMock.Setup(d => d.GetAllRunsForRace(It.IsAny <Race>(), It.IsAny <int>())) .Returns(Task.FromResult( lastRunStatuses.Select(s => new Run { Status = s }) )); runDaoMock.Setup(d => d.InsertMany(It.IsAny <IEnumerable <Run> >())) .Callback <IEnumerable <Run> >(runs => newRunsAdded = runs ); var daoProvider = DaoProviderHelper.GetPartialDaoProvider( raceDao: raceDaoMock.Object, runDao: runDaoMock.Object ); var raceService = new RaceService(daoProvider); // Execute raceService.CompleteRun(new Race(), 1); // Assert runDaoMock.Verify( d => d.InsertMany(It.IsAny <IEnumerable <Run> >()), Times.Once() ); Assert.Equal(2, newRunsAdded.ToArray().Length); }