public async Task <Draw> DrawWinsAsync(Draw draw) { DetermineDrawCanBeDrawn(draw); IEnumerable <Ballot> soldBallots = draw.GetSoldBallots(); int randomIndex = await GenerateRandomNumberAsync(0, soldBallots.Count() - 1); Ballot pickedBallot = soldBallots.ElementAt(randomIndex); Price mainPrice = draw.GetMainPrice(); pickedBallot.WonPrice = mainPrice; Price finalDigitPrice = draw.GetFinalDigitPrice(); IEnumerable <Ballot> finalDigitsBallots = draw.GetSoldBallots(pickedBallot.GetLastDigit()); foreach (var wonBallot in finalDigitsBallots) { if (wonBallot.Number != pickedBallot.Number) { wonBallot.WonPrice = finalDigitPrice; } } draw.RegisterAsDrawn(); return(draw); }
public void GetLastDigit_ReturnsLastDigitOfNumber() { // Arrange var ballot = new Ballot { Number = 1234, }; // Act var result = ballot.GetLastDigit(); // Assert result.Should().Be(4); }