public override void Handle(BrokeredMessage message) { var employeePictureRepository = new EmployeePictureRepository(new MyCompanyContext()); var employeePictureId = message.GetBody <int>(); employeePictureRepository.DeleteAsync(employeePictureId).Wait(); }
public override void Handle(BrokeredMessage message) { var employeePictureRepository = new EmployeePictureRepository(new MyCompanyContext()); var dto = message.GetBody <EmployeePictureDTO>(); var employeePicture = Mapper.Map <EmployeePicture>(dto); employeePictureRepository.UpdateAsync(employeePicture).Wait(); }
public async Task EmployeePictureRepository_DeleteEmployeePicture_NoExists_NotFail_Test() { var context = new MyCompanyContext(); int expected = context.EmployeePictures.Count(); IEmployeePictureRepository target = new EmployeePictureRepository(context); await target.DeleteAsync(0); int actual = context.EmployeePictures.Count(); Assert.AreEqual(expected, actual); }
public async Task EmployeePictureRepository_UpdateEmployeePicture_NotFail_Test() { var context = new MyCompanyContext(); var employeePicture = context.EmployeePictures.FirstOrDefault(); var target = new EmployeePictureRepository(context); employeePicture.PictureType = PictureType.Big; await target.UpdateAsync(employeePicture); var actual = context.EmployeePictures.FirstOrDefault(p => p.EmployeePictureId == employeePicture.EmployeePictureId); Assert.AreEqual((int)employeePicture.PictureType, (int)actual.PictureType); }
///<inheritdoc/> public override void Handle(BrokeredMessage message) { var employeeRepository = new EmployeeRepository(new MyCompanyContext()); var employeePictureRepository = new EmployeePictureRepository(new MyCompanyContext()); var dto = message.GetBody <EmployeePictureDTO>(); var employeePicture = Mapper.Map <EmployeePicture>(dto); if (employeeRepository.Get(employeePicture.EmployeeId) != null) { employeePictureRepository.Update(employeePicture); } }
public async Task EmployeePictureRepository_DeleteEmployeePicture_Deleted_NotFail_Test() { var context = new MyCompanyContext(); var employeePicture = context.EmployeePictures.First(); int expected = context.EmployeePictures.Count() - 1; IEmployeePictureRepository target = new EmployeePictureRepository(new MyCompanyContext()); await target.DeleteAsync(employeePicture.EmployeePictureId); int actual = context.EmployeePictures.Count(); Assert.AreEqual(expected, actual); }
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); }
public void Constructor_ShouldThrowAnExceptionIfContextIsntSupplied() { var target = new EmployeePictureRepository(null); }