public void CreateDrawFor_ShouldGenerateACorrectListOfNumbersAndAddADrawUsingTheRepository() { var someGame = new LotteryGameBuilder().WithId().Build(); _service.CreateDrawFor(someGame); var amountOfRunsToRuleOutRandomness = 10; for (int i = 0; i < amountOfRunsToRuleOutRandomness; i++) { _drawRepositoryMock.Invocations.Clear(); _service.CreateDrawFor(someGame); _drawRepositoryMock.Verify(repo => repo.Add(someGame.Id, It.Is <IList <int> >(numbers => AssertIsValidNumbersList(someGame, numbers))), Times.Once, "The Add method of the repository is not called correctly."); } }
public void CreateDrawFor_ShouldGenerateACorrectDrawAndAddItToTheRepository() { var someGame = new LotteryGameBuilder().WithId().Build(); var now = DateTime.Now; _service.CreateDrawFor(someGame); var amountOfRunsToRuleOutRandomness = 10; for (int i = 0; i < amountOfRunsToRuleOutRandomness; i++) { _drawRepositoryMock.Invocations.Clear(); _service.CreateDrawFor(someGame); _drawRepositoryMock.Verify(repo => repo.Add(It.Is <Draw>(draw => AssertIsValidDraw(draw, someGame, now))), Times.Once, "The draw created by the service should be added using the repository."); } }