示例#1
0
        ///<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);

            var employee = employeeRepository.Get(employeePicture.EmployeeId);

            if (null == employee)
            {
                Thread.Sleep(1000);
            }
            employeePictureRepository.Add(employeePicture);
        }
        public void 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 employeeId        = context.Employees.FirstOrDefault().EmployeeId;

            var employeePicture = new EmployeePicture()
            {
                EmployeePictureId = employeePictureId,
                EmployeeId        = employeeId,
                PictureType       = PictureType.Small,
                Content           = System.Text.Encoding.UTF8.GetBytes("sample"),
            };

            target.Add(employeePicture);

            int actual = context.EmployeePictures.Count();

            Assert.AreEqual(expected, actual);
        }