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); } } }
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); }
public MatchId Id() { return(MatchId.FromGuid(Faker.Random.Guid())); }