public async void ReturnTeamWhichExistsInDbByGivenId() { // Arrange var team = new Team() { Id = 1, FullName = "Manchester United Football Club", ShortName = "Manchester United", City = "Stretford", CreatedAt = 1878, Coach = "Ole Gunnar Solskjær" }; TeamDTO testTeam = null; _repositoryMock.Reset(); _repositoryMock.Setup(r => r.GetByIdAsync(It.IsAny <uint>())).ThrowsAsync(new ArgumentException()); _repositoryMock.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(team); var expectedTeam = _mapper.Map <TeamDTO>(team); // Act var err = await Record.ExceptionAsync(async () => testTeam = await _service.GetByIdAsync(1)); // Assert err.Should().BeNull(); testTeam.Should().NotBeNull(); testTeam.Should().BeEquivalentTo(expectedTeam); }
public async void ReturnNullWhenTeamDoNotExistsInDbByGivenId() { // Arrange TeamDTO testTeam = null; _repositoryMock.Reset(); _repositoryMock.Setup(r => r.GetByIdAsync(It.IsAny <uint>())).ReturnsAsync((Team)null); // Act var err = await Record.ExceptionAsync(async () => testTeam = await _service.GetByIdAsync(1)); // Assert err.Should().BeNull(); testTeam.Should().BeNull(); }