Exemplo n.º 1
0
 public MarkApprovalsController(
     IMarkApprovalService markService,
     IMapper mapper
     )
 {
     _service = markService;
     _mapper  = mapper;
 }
Exemplo n.º 2
0
        public MarkApprovalServiceTest()
        {
            // Arrange
            foreach (var markApproval in TestData.markApprovals)
            {
                _markApprovals.Add(new MarkApproval
                {
                    Mark     = markApproval.Mark,
                    Employee = markApproval.Employee,
                });
            }
            foreach (var mark in TestData.marks)
            {
                _mockMarkRepo.Setup(mock =>
                                    mock.GetById(mark.Id)).Returns(
                    TestData.marks.SingleOrDefault(v => v.Id == mark.Id));

                _repository.Setup(mock =>
                                  mock.GetAllByMarkId(mark.Id)).Returns(
                    _markApprovals.Where(v => v.Mark.Id == mark.Id));
            }
            foreach (var employee in TestData.employees)
            {
                _mockEmployeeRepo.Setup(mock =>
                                        mock.GetById(employee.Id)).Returns(
                    TestData.employees.SingleOrDefault(v => v.Id == employee.Id));
            }

            _repository.Setup(mock =>
                              mock.Add(It.IsAny <MarkApproval>())).Verifiable();
            _repository.Setup(mock =>
                              mock.Delete(It.IsAny <MarkApproval>())).Verifiable();

            _service = new MarkApprovalService(
                _repository.Object,
                _mockMarkRepo.Object,
                _mockEmployeeRepo.Object);
        }