[TestMethod] //task is required for async TestMerhod return type. return type of void not supported public async Task Integration_LogDataContext_LogService_Log_await_GetDataCallInfoSelections_Return_DataCallInfoDto() { bool caught = false; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWork); var logService = new LogService(_logRepository); try { List<DataCallInfoDto> Dtos = null; //awaut cinverts Task<IEnumerable<DataCallInfoDto>> to IEnumerable<DataCallInfoDto> IEnumerable<DataCallInfoDto> DataCallInfoDtos = await logService.GetDataCallInfoSelections("default"); //GetDataCallInfoSelections() is async method of Logservice. //awaut on logService.GetDataCallInfoSelections() runs asynchronously //converts return type toTask<IEnumerable<DataCallInfoDto>> to IEnumerable<DataCallInfoDto> //it will return a IEnumerable<DataCallInfoDto> //This must be converted to a List<DataCallInfoDto> that is used in the asseert. Dtos = DataCallInfoDtos as List<DataCallInfoDto>; Assert.IsNotNull(Dtos); Assert.IsInstanceOfType(DataCallInfoDtos, typeof(IEnumerable<DataCallInfoDto>)); Assert.IsInstanceOfType(Dtos[0].RadioNames, typeof(ICollection<RadioNamestype>)); Assert.IsInstanceOfType(Dtos[0].StationNames, typeof(ICollection<StationNamestype>)); Assert.IsInstanceOfType(Dtos[0].ContestNames, typeof(ICollection<ContestNamestype>)); Assert.AreNotEqual(string.Empty, Dtos[0].SelectedCall ); var LogIDDto = Dtos.Where(x => x.LogId == 1).SingleOrDefault(); Assert.IsNotNull(LogIDDto); Assert.AreEqual(1, LogIDDto.LogId ); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogService_Log_await_GetDataCallInfoSelections_Return_DataCallInfoDtoo exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception } }