public async Task SaveAsyncWhenSaveReturnsSaved() { //Arrange var mockIllnessRepository = GetDefaultIIllnessRepositoryInstance(); var mockPetIllnessRepository = GetDefaultIPetIllnessRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Illness illness = new Illness { Id = 10, Name = "Diabetes" }; mockIllnessRepository.Setup(r => r.AddAsync(illness)) .Returns(Task.FromResult <Illness>(illness)); var service = new IllnessService(mockUnitOfWork.Object, mockPetIllnessRepository.Object, mockIllnessRepository.Object); //Act IllnessResponse result = await service.SaveAsync(illness); //Assert result.Resource.Should().Be(illness); }
public async Task GetByIdAsyncWhenNoCityFoundReturnsIllnesNotFoundResponse() { //Arrange var mockIllnessRepository = GetDefaultIIllnessRepositoryInstance(); var mockPetIllnessRepository = GetDefaultIPetIllnessRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var illnessId = 1; mockIllnessRepository.Setup(r => r.FindById(illnessId)) .Returns(Task.FromResult <Illness>(null)); var service = new IllnessService(mockUnitOfWork.Object, mockPetIllnessRepository.Object, mockIllnessRepository.Object); //Act IllnessResponse result = await service.GetByIdAsync(illnessId); var message = result.Message; //Assert message.Should().Be("Illness not found"); }