public static MatchEvent ToDomain(this Entities.MatchEvent matchEvent) => new MatchEvent( UserId.CreateUserId(matchEvent.UserId).IfNone(new UserId()), MatchId.CreateMatchId(matchEvent.MatchId).IfNone(new MatchId()), matchEvent.EventTime, (MatchEventType)matchEvent.MatchEventType );
public async void TestGetAllEventsByUserId() { // Assemble var matchEvents = new List <MatchEvent>() { new MatchEvent( UserId.CreateUserId(42).IfNone(new UserId()), MatchId.CreateMatchId(22).IfNone(new MatchId()), DateTime.Now.AddDays(-1), MatchEventType.Conversion ), new MatchEvent( UserId.CreateUserId(42).IfNone(new UserId()), MatchId.CreateMatchId(22).IfNone(new MatchId()), DateTime.Now.AddDays(-1), MatchEventType.Conversion ) }; Either <IEnumerable <Error>, List <MatchEvent> > returnValue = Right(matchEvents); _matchEventRepository.Setup(m => m.GetAllMatchEventsByUserIdAsync(It.IsAny <UserId>(), It.IsAny <MatchId>())).Returns(Task.FromResult(returnValue)); // Act var result = await _matchEventService.GetAllMatchEventsByUserIdAsync(42, 22); // Assert _matchEventRepository.Verify(w => w.GetAllMatchEventsByUserIdAsync(It.IsAny <UserId>(), It.IsAny <MatchId>())); result.Match( Left: (err) => Assert.False(true, "Expected no errors to be returned."), Right: (matchEvents) => Assert.Equal(2, matchEvents.Count) ); }