public async Task MoveNext_HappyPath_RandomSort() { var taskGenerator = new TaskGenerator(); mockTaskRepository.Setup(tr => tr.ReadAsync(It.IsAny <ContestType>())).Returns(Task.FromResult(new Result <IEnumerable <TaskBase> >(taskGenerator.GetAllTasksAsList()))); mockTaskRepository.Setup(tr => tr.ReadAsync(It.IsAny <string>())) .Returns <string>((id) => Task.FromResult(new Result <TaskBase>(taskGenerator.GetAllTasksAsList().Where(t => t.Id == id).Single()))); var allPilots = ContestThatHasStartedData_RandomSort.GetAllPilots(); mockPilotRepository.Setup(p => p.ReadAsync()).Returns(Task.FromResult(new Result <IEnumerable <Pilot> >(allPilots))); mockFlightMatrixRepository.Setup(fmr => fmr.ReadAsync(It.IsAny <string>())).Returns(Task.FromResult(ContestThatHasStartedData_RandomSort.GetFlightMatrix())); // We are testing random sort mockAlgo.Setup(algo => algo.IsSingleRoundSort()).Returns(false); var contestEngine = new F3KContestEngine( new TaskQueryInteractor(mockTaskRepository.Object, mockLogger.Object), new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object), new ScoringStorageCmdInteractor(mockScoringRepository.Object, mockLogger.Object), new ScoringQueryInteractor(mockScoringRepository.Object, mockLogger.Object), new ScoringContestScoreAggInteractor(mockContestScoreAggrigator.Object, mockLogger.Object), new FlightMatrixStorageCmdInteractor(mockFlightMatrixRepository.Object, mockLogger.Object), new FlightMatrixQueryInteractor(mockFlightMatrixRepository.Object, mockLogger.Object), new PilotQueryInteractor(mockPilotRepository.Object, mockLogger.Object), mockAlgo.Object, new Top10PilotsFlyoffsSort(), mockLogger.Object); var contest = ContestThatHasStartedData_RandomSort.GetContest(); await contestEngine.Initialize(ContestThatHasStartedData_RandomSort.GetContest()); Assert.AreEqual(0, contestEngine.CurrentRoundOrdinal); Assert.AreEqual(FlightGroup.B, contestEngine.CurrentFlightGroup); Assert.IsNotNull(contestEngine.CurrentTask as TaskA_LastFlightSevenMin); await contestEngine.MoveToNextContestStage(); Assert.AreEqual(0, contestEngine.CurrentRoundOrdinal); Assert.AreEqual(FlightGroup.C, contestEngine.CurrentFlightGroup); // Set up the repository to return an appropriate updated contest for this test. var updatedContest = ContestThatHasStartedData_RandomSort.GetContest(); updatedContest.State.CurrentFlightGroup = FlightGroup.A; updatedContest.State.CurrentRoundOrdinal = 1; mockContestRepository.Setup(cr => cr.UpdateAsync(It.IsAny <Contest>())).Returns(Task.FromResult <Result <Contest> >(new Result <Contest>(updatedContest))); await contestEngine.MoveToNextContestStage(); Assert.AreEqual(1, contestEngine.CurrentRoundOrdinal); Assert.AreEqual(FlightGroup.A, contestEngine.CurrentFlightGroup); Assert.IsNotNull(contestEngine.CurrentTask as TaskB_LastTwoFlights4MinMax); }
public async Task MoveNext_HappyPath_MoMSort() { var taskGenerator = new TaskGenerator(); mockTaskRepository.Setup(tr => tr.ReadAsync(It.IsAny <string>())) .Returns <string>((id) => Task.FromResult(new Result <TaskBase>(taskGenerator.GetAllTasksAsList().Where(t => t.Id == id).Single()))); mockTaskRepository.Setup(tr => tr.ReadAsync(It.IsAny <ContestType>())) .Returns(Task.FromResult(new Result <IEnumerable <TaskBase> >(taskGenerator.GetAllTasksAsList()))); var allPilots = ContestThatHasStarted_MoMSort_FirstRound.GetPilots(); mockPilotRepository.Setup(p => p.ReadAsync()).Returns(Task.FromResult(new Result <IEnumerable <Pilot> >(allPilots))); mockScoringRepository.Setup(s => s.ReadAsync(It.IsAny <string>())).Returns(Task.FromResult(new Result <ContestScoresCollection>(ContestThatHasStarted_MoMSort_FirstRound.GetScores()))); var algo = new MoMSingleRoundSort(); var contestScoreAggrigator = new ContestScoreAggregatorWithDrop(); var contestEngine = new F3KContestEngine( new TaskQueryInteractor(mockTaskRepository.Object, mockLogger.Object), new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object), new ScoringStorageCmdInteractor(mockScoringRepository.Object, mockLogger.Object), new ScoringQueryInteractor(mockScoringRepository.Object, mockLogger.Object), new ScoringContestScoreAggInteractor(contestScoreAggrigator, mockLogger.Object), new FlightMatrixStorageCmdInteractor(mockFlightMatrixRepository.Object, mockLogger.Object), new FlightMatrixQueryInteractor(mockFlightMatrixRepository.Object, mockLogger.Object), new PilotQueryInteractor(mockPilotRepository.Object, mockLogger.Object), algo, new Top10PilotsFlyoffsSort(), mockLogger.Object); await contestEngine.Initialize(ContestThatHasStarted_MoMSort_FirstRound.GetContest()); Assert.AreEqual(0, contestEngine.CurrentRoundOrdinal); Assert.AreEqual(FlightGroup.C, contestEngine.CurrentFlightGroup); await contestEngine.MoveToNextContestStage(); Assert.AreEqual(1, contestEngine.CurrentRoundOrdinal); Assert.AreEqual(FlightGroup.A, contestEngine.CurrentFlightGroup); //Assert.IsNotNull(contestEngine.Contest.); }