public async Task Test_FetchPostCodeUnitForBasicSearch() { var result = await testCandidate.GetPostcodeUnitForBasicSearch("abc", Guid.NewGuid()); Assert.NotNull(result); Assert.AreEqual(result.ToList()[0].PostcodeUnit, "Unit1"); }
public async Task <IEnumerable <PostcodeDTO> > GetPostcodeUnitForBasicSearch(string searchText) { string methodName = typeof(UnitManagerController) + "." + nameof(GetPostcodeUnitForBasicSearch); using (loggingHelper.RMTraceManager.StartTrace("WebService.GetPostcodeUnitForBasicSearch")) { if (string.IsNullOrEmpty(searchText)) { throw new ArgumentNullException(nameof(searchText)); } loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodEntryEventId); try { var postcodeUnits = await unitLocationBusinessService.GetPostcodeUnitForBasicSearch(searchText, CurrentUserUnit); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodEntryEventId); return(postcodeUnits); } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } } }