public override void Handle(BrokeredMessage message) { var employeePictureRepository = new EmployeePictureRepository(new MyCompanyContext()); var employeeRepository = new EmployeeRepository(new MyCompanyContext()); var dto = message.GetBody <EmployeePictureDTO>(); var employeePicture = Mapper.Map <EmployeePicture>(dto); var employee = employeeRepository.GetAsync(employeePicture.EmployeeId).Result; if (null == employeePicture) { Thread.Sleep(1000); } employeePictureRepository.AddAsync(employeePicture).Wait(); }
public async Task EmployeePictureRepository_AddEmployeePicture_Added_NotFail_Test() { var context = new MyCompanyContext(); int expected = context.EmployeePictures.Count() + 1; var target = new EmployeePictureRepository(context); var employeePictureId = context.EmployeePictures.Select(e => e.EmployeePictureId).Max() + 1; var employeePicture = new EmployeePicture() { EmployeePictureId = employeePictureId, EmployeeId = 1, PictureType = PictureType.Small, Content = System.Text.Encoding.UTF8.GetBytes("sample"), }; await target.AddAsync(employeePicture); int actual = context.EmployeePictures.Count(); Assert.AreEqual(expected, actual); }