public void AuditoriumService_GetByIdAsync_RepositoryReturnsNull_ReturnsNull() { //Arrange Auditorium nullAuditorium = null; Task <Auditorium> auditorium = Task.FromResult(nullAuditorium); AuditoriumService auditoriumService = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockProjectionService.Object, _mockSeatService.Object); _mockAuditoriumsRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(auditorium); //Act var result = auditoriumService.GetByIdAsync(_auditorium.Id).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(result); }
public void AuditoriumService_GetByIdAsync_ReturnsAuditoriumModel() { //Arrange Task <Auditorium> auditorium = Task.FromResult(_auditorium); AuditoriumService auditoriumService = new AuditoriumService(_mockAuditoriumsRepository.Object, _mockProjectionService.Object, _mockSeatService.Object); _mockAuditoriumsRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).Returns(auditorium); //Act var result = auditoriumService.GetByIdAsync(_auditorium.Id).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(AuditoriumDomainModel)); Assert.AreEqual(result.Id, _auditorium.Id); }