public async void ReturnLeagueWhichExistsInDbByGivenId() { // Assert var league = new League() { Id = 1, Name = "Primera Division", Country = "Spain", Season = "2018/2019", MVP = new Player() { Name = "Lionel", Surname = "Messi" }, Winner = new Team() { ShortName = "FC Barcelona" } }; LeagueDTO testLeague = null; _repositoryMock.Reset(); _repositoryMock.Setup(r => r.GetByIdAsync(It.IsAny <uint>())).ThrowsAsync(new ArgumentException()); _repositoryMock.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(league); var expectedLeague = _mapper.Map <LeagueDTO>(league); // Act var err = await Record.ExceptionAsync(async () => testLeague = await _service.GetByIdAsync(1)); // Arrange err.Should().BeNull(); testLeague.Should().NotBeNull(); testLeague.Should().BeEquivalentTo(expectedLeague); }
public async void ReturnNullWhenLeagueDoNotExistsInDbByGivenId() { // Assert LeagueDTO testLeague = null; _repositoryMock.Reset(); _repositoryMock.Setup(r => r.GetByIdAsync(It.IsAny <uint>())).ReturnsAsync((League)null); // Act var err = await Record.ExceptionAsync(async () => testLeague = await _service.GetByIdAsync(1)); // Arrange err.Should().BeNull(); testLeague.Should().BeNull(); }