public async void TestAddNewMatchEventAsyncSuccess() { // Assemble var newMatchEvent = GetSampleMatchEvent(); Either <IEnumerable <Error>, int> returnValue = Right(1); _matchEventRepository .Setup(w => w.AddNewMatchEventAsync(It.IsAny <Gametracker.Services.Domain.MatchEvent>())) .Returns(Task.FromResult(returnValue)); // Act var result = await _matchEventService.AddNewMatchEventAsync(newMatchEvent); // Assert _matchEventRepository.Verify(w => w.AddNewMatchEventAsync(It.IsAny <Gametracker.Services.Domain.MatchEvent>())); result.Match( Left: (err) => Assert.False(true, "Expected no errors to be returned."), Right: (newId) => Assert.Equal(1, newId) ); }
public async Task <ActionResult <int> > AddNewMatchEventAsync(Ianf.Gametracker.Services.Dto.MatchEvent matchEvent) { var result = await _matchEventService.AddNewMatchEventAsync(matchEvent); ActionResult <int> returnValue = Ok(); return(result.Match( Left: (err) => returnValue = BadRequest(err), Right: (newMatchEventId) => returnValue = Ok(newMatchEventId) )); }