public async Task SaveAsyncWhenSaveReturnsSaved() { //Arrange var mockVetProfileRepository = GetDefaultIVetProfileRepositoryInstance(); var mockVetVeterinaryRepository = GetDefaultIVetVeterinaryRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var mockCityRepository = GetDefaultICityRepositoryInstance(); var mockProvinceRepository = GetDefaultIProvinceRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); User user = new User { Id = 1, Mail = "*****@*****.**", UserTypeVet = true }; Province province = new Province { Id = 1, Name = "Lima" }; City city = new City { Id = 10, Name = "SJL", ProvinceId = 1 }; VetProfile vetProfile = new VetProfile { Id = 10, Name = "Jose", Code = 15 }; mockUserRepository.Setup(p => p.AddAsync(user)) .Returns(Task.FromResult <User>(user)); mockUserRepository.Setup(p => p.FindByIdAsync(1)) .Returns(Task.FromResult <User>(user)); mockProvinceRepository.Setup(p => p.AddAsync(province)) .Returns(Task.FromResult <Province>(province)); mockProvinceRepository.Setup(p => p.FindById(1)) .Returns(Task.FromResult <Province>(province)); mockCityRepository.Setup(r => r.AddAsync(city)) .Returns(Task.FromResult <City>(city)); mockCityRepository.Setup(p => p.FindById(10)) .Returns(Task.FromResult <City>(city)); mockVetProfileRepository.Setup(r => r.AddAsync(vetProfile)) .Returns(Task.FromResult <VetProfile>(null)); var service = new VetProfileService(mockVetProfileRepository.Object, mockVetVeterinaryRepository.Object, mockUnitOfWork.Object, mockProvinceRepository.Object, mockCityRepository.Object, mockUserRepository.Object); //Act VetProfileResponse result = await service.SaveAsync(1, 10, 1, vetProfile); //Assert result.Resource.Should().Be(vetProfile); }