public MarkGeneralDataPointsController( IMarkGeneralDataPointService markGeneralDataPointService, IMapper mapper) { _service = markGeneralDataPointService; _mapper = mapper; }
public MarkService( IMarkRepo markRepo, ISubnodeRepo subnodeRepo, IDepartmentRepo departmentRepo, IEmployeeRepo employeeRepo, IEstimateTaskRepo estimateTaskRepo, ISpecificationService specificationService, IMarkGeneralDataPointService markGeneralDataPointService) { _repository = markRepo; _subnodeRepo = subnodeRepo; _departmentRepo = departmentRepo; _employeeRepo = employeeRepo; _estimateTaskRepo = estimateTaskRepo; _specificationService = specificationService; _markGeneralDataPointService = markGeneralDataPointService; }
public MarkGeneralDataPointServiceTest() { // Arrange foreach (var mgdp in TestData.markGeneralDataPoints) { _markGeneralDataPoints.Add(new MarkGeneralDataPoint { Id = mgdp.Id, Mark = mgdp.Mark, Section = mgdp.Section, Text = mgdp.Text, OrderNum = mgdp.OrderNum, }); } foreach (var markGeneralDataPoint in _markGeneralDataPoints) { _repository.Setup(mock => mock.GetById(markGeneralDataPoint.Id)).Returns( _markGeneralDataPoints.SingleOrDefault(v => v.Id == markGeneralDataPoint.Id)); } 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( _markGeneralDataPoints.Where(v => v.Mark.Id == mark.Id)); foreach (var generalDataSection in TestData.generalDataSections) { _repository.Setup(mock => mock.GetAllByMarkAndSectionId(mark.Id, generalDataSection.Id)).Returns( _markGeneralDataPoints.Where( v => v.Mark.Id == mark.Id && v.Section.Id == generalDataSection.Id)); foreach (var markGeneralDataPoint in _markGeneralDataPoints) { _repository.Setup(mock => mock.GetByUniqueKey( mark.Id, generalDataSection.Id, markGeneralDataPoint.Text)).Returns( _markGeneralDataPoints.SingleOrDefault( v => v.Mark.Id == mark.Id && v.Section.Id == generalDataSection.Id && v.Text == markGeneralDataPoint.Text)); } } } foreach (var generalDataSection in TestData.generalDataSections) { _mockGeneralDataSectionRepo.Setup(mock => mock.GetById(generalDataSection.Id)).Returns( TestData.generalDataSections.SingleOrDefault( v => v.Id == generalDataSection.Id)); } foreach (var generalDataPoint in TestData.generalDataPoints) { _mockGeneralDataPointRepo.Setup(mock => mock.GetById(generalDataPoint.Id)).Returns( TestData.generalDataPoints.SingleOrDefault( v => v.Id == generalDataPoint.Id)); } _repository.Setup(mock => mock.Add(It.IsAny <MarkGeneralDataPoint>())).Verifiable(); _repository.Setup(mock => mock.Update(It.IsAny <MarkGeneralDataPoint>())).Verifiable(); _repository.Setup(mock => mock.Delete(It.IsAny <MarkGeneralDataPoint>())).Verifiable(); _service = new MarkGeneralDataPointService( _repository.Object, _mockMarkRepo.Object, _mockGeneralDataSectionRepo.Object, _mockGeneralDataPointRepo.Object); }