public GetWasteCodeLookupAndNotificationDataByTypesHandlerTests() { wasteCodeRepository = A.Fake <IWasteCodeRepository>(); notificationApplicationRepository = A.Fake <INotificationApplicationRepository>(); //var context = new TestIwsContext(); handler = new GetWasteCodeLookupAndNotificationDataByTypesHandler(notificationApplicationRepository, wasteCodeRepository, new WasteCodeMap(), new WasteCodeMap()); A.CallTo(() => wasteCodeRepository.GetAllWasteCodes()).Returns(wasteCodes); var notificationWithWasteCodes = new TestableNotificationApplication { Id = NotificationWithWasteCodesId, WasteCodes = new WasteCodeInfo[] { new TestableWasteCodeInfo(FirstBaselCode) } }; A.CallTo(() => notificationApplicationRepository.GetById(NotificationWithWasteCodesId)).Returns(notificationWithWasteCodes); var notificationWithoutWasteCodes = new TestableNotificationApplication { Id = NotificationWithoutWasteCodesId }; A.CallTo(() => notificationApplicationRepository.GetById(NotificationWithoutWasteCodesId)).Returns(notificationWithoutWasteCodes); }
public GetWasteCodesByTypeHandlerTests() { wasteCodeRepository = A.Fake <IWasteCodeRepository>(); handler = new GetWasteCodesByTypeHandler(wasteCodeRepository, new WasteCodeMap()); A.CallTo(() => wasteCodeRepository.GetAllWasteCodes()).Returns(wasteCodes); }
public async Task <IList <WasteCodeData> > HandleAsync(GetAllWasteCodes message) { var result = await repository.GetAllWasteCodes(); return(result .Select(wasteCode => mapper.Map <WasteCodeData>(wasteCode)) .ToList()); }
public async Task <WasteCodeData[]> HandleAsync(GetWasteCodesByType message) { IEnumerable <WasteCode> result; if (message.CodeTypes == null || message.CodeTypes.Length == 0) { result = await wasteCodeRepository.GetAllWasteCodes(); } else { result = await wasteCodeRepository.GetAllWasteCodes(); result = result .Where(p => message.CodeTypes.Contains(p.CodeType)) .ToArray(); } return(result.Select(c => mapper.Map(c)).OrderBy(m => m.Code).ToArray()); }
public async Task <WasteTypes> HandleAsync(GetImportNotificationWasteTypes message) { var wasteTypes = await wasteTypeRepository.GetByNotificationId(message.ImportNotificationId); var wasteCodeData = (await wasteCodeRepository.GetAllWasteCodes()).Select(wasteCode => mapper.Map <WasteCodeData>(wasteCode)) .ToList(); return(mapper.Map <WasteTypes>(wasteTypes, wasteCodeData)); }
private async Task <IList <WasteCode> > GetLookupCodes(GetWasteCodeLookupAndNotificationDataByTypes message) { if (message.LookupWasteCodeTypes.Count == 0) { return(new WasteCode[0]); } IEnumerable <WasteCode> result; result = await wasteCodeRepository.GetAllWasteCodes(); return (result .Where(wc => message.LookupWasteCodeTypes.Contains(wc.CodeType)) .ToArray()); }