Beispiel #1
0
        public async Task FindMatchAsync_ShouldBeEquivalentToMatch(Game game, ChallengeState state)
        {
            //Arrange
            var challengeFaker = TestData.FakerFactory.CreateChallengeFaker(83459632, game, state);

            var challenge = challengeFaker.FakeChallenge();

            using var factory = new InMemoryDbContextFactory <ChallengesDbContext>();

            await using (var context = factory.CreateContext())
            {
                var challengeRepository = new ChallengeRepository(context);

                challengeRepository.Create(challenge);

                await challengeRepository.CommitAsync();
            }

            await using (var context = factory.CreateContext())
            {
                var matchQuery = new MatchQuery(context);

                foreach (var match in challenge.Participants.SelectMany(participant => participant.Matches).ToList())
                {
                    //Act
                    var matchAsync = await matchQuery.FindMatchAsync(MatchId.FromGuid(match.Id));

                    //Arrange
                    matchAsync.Should().BeEquivalentTo(match);
                }
            }
        }