public async void UpdateApplication_ApplicationExists_CallRepositoryUpdateAndReturnsUpdatedJobApplication() { // Arrange const string companyName = "Company 1"; var jobApplicationEntities = (IEnumerable <JobApplicationEntity>)_jobApplicationEntities; var jobApplicationEntity = jobApplicationEntities.First(x => x.CompanyName.Equals(companyName)); _jobApplicationRepository.GetOne(Arg.Any <Expression <Func <JobApplicationEntity, bool> > >()).Returns(jobApplicationEntity); _mapper.Map <JobApplication>(jobApplicationEntity).Returns(_jobApplications[0]); _userResolver.GetCurrentUser().Returns(_user); // Act var jobApplication = await _jobApplicationService.UpdateApplication(_jobApplications[0].CompanyName, _jobApplications[0]) .ConfigureAwait(false); // Assert await _jobApplicationRepository.Received().Update(_jobApplicationEntities[0]).ConfigureAwait(false); Assert.Equal(_jobApplications[0], jobApplication); }