예제 #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);
                }
            }
        }
예제 #2
0
        public static IMatch ToEntity(this MatchModel model)
        {
            var match = new Match(
                model.GameUuid,
                new DateTimeProvider(model.GameStartedAt),
                TimeSpan.FromTicks(model.GameDuration),
                model.Stats.Select(stat => stat.ToEntity()),
                new DateTimeProvider(model.SynchronizedAt));

            match.SetEntityId(MatchId.FromGuid(model.Id));

            match.ClearDomainEvents();

            return(match);
        }
예제 #3
0
 public MatchId Id()
 {
     return(MatchId.FromGuid(Faker.Random.Guid()));
 }