public void Integration_LogDataContext_URF_QueryFluent_CallInfo_Include_StationCallsign_Return_StationCallsign() { List<CallInfo> callis = null; using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWorkData = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<CallInfo> _CallinfoRepository = new Repository<CallInfo>(context, unitOfWorkData); try { TestContext.WriteLine("Integration_LogDataContext_URF_QueryFluent_CallInfo_Include_StationCallsign_Return_StationCallsign"); //tracked callis = _CallinfoRepository.Query(x => x.UserName == "default") .Include(x => x.Station).Include(x => x.CallSign) .Select().OrderBy(t => t.SessionName).ThenBy(t => t.CallGroup) .ToList(); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_URF_QueryFluent_CallInfo_Include_StationCallsign_Return_StationCallsign exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(callis); Assert.IsInstanceOfType(callis, typeof(List<CallInfo> ) ); Assert.AreEqual(3, callis.Count ); Assert.IsNotNull(callis[0].CallSign); Assert.IsNotNull(callis[0].Station); } }
public void Integration_LogDataContext_URF_QueryableTrack_IncludeParam_Station_Return_Station_Track() { List<CallInfo> callis = null; IQueryable<CallInfo> CallInfo1 = null; using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<CallInfo> _CallinfoRepository = new Repository<CallInfo>(context, unitOfWork); try { //var LogQ = _logRepository.Queryable(x => x.LogId == 1, x => x.Stations, x => x.CallSign); //CallInfo1 = _CallinfoRepository.Item(x => x.UserName == "default", x => x.Station); CallInfo1 = _CallinfoRepository.QueryableTrack(false, x => x.UserName == "default", x => x.Station); callis = CallInfo1.ToList(); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_URF_QueryableTrack_IncludeParam_Station_Return_Station_Track exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(CallInfo1); Assert.IsInstanceOfType(CallInfo1, typeof(IQueryable<CallInfo>)); Assert.AreEqual(3, callis.Count ); //check if tracked //Assert.AreEqual(CallInfo1.Where(z=>z.CallGroup == (int)CallGroupEnum.CALL1).Select(x=>x.CallsignId).SingleOrDefault().)) Assert.AreEqual(Infrastructure.ObjectState.Unchanged, callis[0].ObjectState); Assert.IsNull(callis[0].CallSign); Assert.IsNotNull(callis[0].Station); Assert.IsTrue(_CallinfoRepository.GetEntityTrackingState(callis[0])); } }
public void Integration_LogDataContext_LogService_Log_GetLogById_Return_Log() { Logqso.mvc.Entities.LogDataEntity.Log LogforId1 = null; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB using (IUnitOfWorkAsync unitOfWorkData = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWorkData); var logService = new LogService(_logRepository); try { var Logtask= logService.GetLogById(LogId); LogforId1 = Logtask.Result; } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogService_Log_GetLogById_Return_Log exception {0}",ex.Message) ); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(LogforId1); Assert.IsInstanceOfType(LogforId1, typeof(Logqso.mvc.Entities.LogDataEntity.Log)); Assert.AreEqual(LogId, LogforId1.LogId); Assert.IsInstanceOfType(LogforId1.ContestYear, typeof(DateTime)); Assert.AreEqual( 1,LogforId1.CallsignId ); } }
public void Integration_LogDataContext_LogService_Query_Log_Include_LogCategory_Return_LogCategories() { List<Logqso.mvc.Entities.LogDataEntity.Log> LogforId1s = null; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWork); var logService = new LogService(_logRepository); try { var Logtask = logService.Query(x => x.LogId == 1) .Include(x => x.LogCategory) .Select(); LogforId1s = Logtask.ToList(); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogService_Log_GetLogById_Return_Log exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(LogforId1s); Assert.IsTrue(LogforId1s.Count > 0); Assert.IsInstanceOfType(LogforId1s[0], typeof(Logqso.mvc.Entities.LogDataEntity.Log)); Assert.AreEqual(LogId, LogforId1s[0].LogId ); Assert.IsInstanceOfType(LogforId1s[0].ContestYear, typeof(DateTime)); Assert.AreEqual(1, LogforId1s[0].CallsignId ); Assert.IsNotNull(LogforId1s[0].LogCategory); } }
public void Integration_LogDataContext_URF_GetDbContext_SqlQuery_ChartQsoRateDTO_Return_ChartQsoRateDTOList() { using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWorkData = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Qso> QsoRepository = new Repository<Qso>(context, unitOfWorkData); List<ChartQsoRateDTO> ChartQsoRateDTOList = null; try { string sQSOQuery = "use ContestqsoDataTest " + //"SELECT [Time1] AS IntvTime, Sum(Qry5minintervals.N) AS N FROM (SELECT convert(datetime, Format([Qso].[QsoDateTime],'d') + ' ' + Format(DatePart(hh,[Qso].[QsoDateTime]),'00') + ':' + Format((DatePart(n,[Qso].[QsoDateTime])/60)*60,'00') )AS [Time1] , Count(*) AS N FROM Qso INNER JOIN Log ON [Qso].[LogId] = [Log].[LogId] INNER JOIN CallSign ON [Qso].[CallsignId] = [CallSign].[CallSignId] AND [Log].[LogId] = 1 GROUP BY [Qso].[QsoDateTime] ) AS Qry5minintervals GROUP BY [Time1] ORDER By 1 asc"; "SELECT [Time1] AS IntvTime, Sum(Qry5minintervals.N) AS N " + " FROM (SELECT convert(datetime, Format([Qso].[QsoDateTime],'d') + ' ' + " + "Format(DatePart(hh,[Qso].[QsoDateTime]),'00') + ':' +" + "Format((DatePart(n,[Qso].[QsoDateTime])/60)*60,'00') )" + "AS [Time1] , Count(*) AS N " + "FROM Qso INNER JOIN Log ON [Qso].[LogId] = [Log].[LogId] " + "INNER JOIN CallSign ON [Qso].[CallsignId] = [CallSign].[CallSignId] AND " + "[Log].[LogId] = 1 " + "GROUP BY [Qso].[QsoDateTime] ) AS Qry5minintervals " + "GROUP BY [Time1] ORDER By 1 asc"; TestContext.WriteLine("Integration_LogDataContext_URF_GetDbContext_SqlQuery_ChartQsoRateDTO_Return_ChartQsoRateDTOList"); #if false //tracked //EXAMPLES using (var ctx = new ContestqsoDataContext()) { var list1 = ctx.Stations.SqlQuery("Select * from Station").ToList<Station>(); var list2 = ctx.Database.SqlQuery<string>("Select Station.Stationname from Station ").ToList(); sQSOQuery = "use ContestqsoDataTest " + "select QsoDateTime from Qso where Qso.Logid = 1 "; var list3 = ctx.Database.SqlQuery<DateTime>(sQSOQuery).ToList(); //SQL //use ContestqsoDataTest // select QsoDateTime as IntvTime, Count(*) as N // from QSO where Qso.Logid = 1 // group by QsoDateTime sQSOQuery = "use ContestqsoDataTest " + " select [Qso].[QsoDateTime] as IntvTime, Count(*) as N " + " from [QSO] where [Qso].[Logid] = 1 " + " group by [Qso].[QsoDateTime]"; var list4 = ctx.Database.SqlQuery<ChartQsoRateDTO>(sQSOQuery).ToList(); sQSOQuery = "use ContestqsoDataTest " + " select [Qso].[QsoDateTime] as IntvTime, Count(*) as N " + " from [QSO] where [Qso].[Logid] = 1 " + " group by [Qso].[QsoDateTime]"; //the new ChartQsoRateDTO is not required sunce the 'as' maps directly to ChartQsoRateDTO members var list5 = ctx.Database.SqlQuery<ChartQsoRateDTO>(sQSOQuery) .Select (p=> new ChartQsoRateDTO { IntvTime = p.IntvTime, N = p.N }).ToList(); sQSOQuery = "use ContestqsoDataTest " + "SELECT [Time1] AS IntvTime, Sum(Qry5minintervals.N) AS N " + " FROM (SELECT Format([Qso].[QsoDateTime],'d') " + " + ' ' + Format(DatePart(hh,[Qso].[QsoDateTime]),'00') " + " + ':' + Format((DatePart(n,[Qso].[QsoDateTime])/60)*60,'00')AS [Time1] , " + " Count(*) AS N " + " FROM Qso INNER JOIN Log ON Qso.LogId = log.LogId " + " INNER JOIN CallSign ON [Qso].[CallsignId] = [CallSign].[CallSignId] " + " AND Log.LogId = 1 " + " GROUP BY [Qso].[QsoDateTime] ) AS Qry5minintervals " + " GROUP BY [Time1] "; var list6 = ChartQsoRateDTOList = ctx.Database.SqlQuery<ChartQsoRateDTO>(sQSOQuery).ToList(); } #endif //DbContext = context as DbContext; //var vals = DbContext.Database.SqlQuery<ChartQsoRateDTO>(sQSOQuery).ToList(); ContestqsoDataContext ContestqsoDataContext = QsoRepository.GetDbContext() as ContestqsoDataContext; ChartQsoRateDTOList = ContestqsoDataContext.Database.SqlQuery<ChartQsoRateDTO>(sQSOQuery) .Select(p => new ChartQsoRateDTO { IntvTime = p.IntvTime, N = p.N }).OrderBy(p=>p.IntvTime).ToList(); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_URF_GetDbContext_SqlQuery_ChartQsoRateDTO_Return_ChartQsoRateDTOList {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(ChartQsoRateDTOList); Assert.IsInstanceOfType(ChartQsoRateDTOList, typeof(List<ChartQsoRateDTO>)); Assert.AreEqual(1,ChartQsoRateDTOList.Count ); Assert.IsNotNull(ChartQsoRateDTOList[0].IntvTime == DateTime.Parse("10/26/2002 00:00") ); Assert.IsNotNull(ChartQsoRateDTOList[0].N == 2); } }
public void Integration_LogDataContext_URF_Query_DataCallInfoDto_Include_StationCallInfoContestType_Return_DataCallInfoDto() { List<DataCallInfoDto> DataCallInfoDtos = null; bool Active = true; using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<CallInfo> _CallinfoRepository = new Repository<CallInfo>(context, unitOfWork); try { //var CallInfoss = _CallinfoRepository.QueryableNoTracking(); IQueryFluent<CallInfo> CallInfoss = _CallinfoRepository.Query(t => t.UserName == "default"); var CallInfoQ = CallInfoss .Include(x => x.Station).Include(x => x.CallSign).Include(x => x.QsoRadioType) .SelectQueryable(true) .OrderBy(t => t.SessionName).ThenBy(t => t.CallGroup); var LogRepository = _CallinfoRepository.GetRepository<Log>(); IQueryFluent<Log> Logs = LogRepository.Query(); var LogQ = Logs .Include(x => x.Stations) .Include(x => x.Contest) .SelectQueryable(true); var ContestRepository = LogRepository.GetRepository<Contest>(); IQueryFluent<Contest> Contestss = ContestRepository.Query(); var ContestQ = Contestss .SelectQueryable(true).Where(x => x.Active == Active); var RadioRepository = _CallinfoRepository.GetRepository<QsoRadioType>(); IQueryFluent<QsoRadioType> RadioTypess = RadioRepository.Query(); var RadioQ = RadioTypess .SelectQueryable(true); DataCallInfoDtos = (from lc in CallInfoQ join lq in LogQ on lc.LogId equals lq.LogId where lc.UserName == "default" select new DataCallInfoDto { CallGroup = (CallGroupEnum)lc.CallGroup, SelectedContestName = lc.ContestId, SelectedCall = lc.CallSign.Call, SelectedStationName = lc.Station.StationName, QsoRadioType = (QsoRadioTypeEnum)lc.QsoRadioTypeEnum, //Selecct() flattens StationNames = (from cn in lq.Stations select new StationNamestype { key = cn.LogId, value = cn.StationName }).ToList(), LogId = lc.LogId, //returns only contests that match the Callinfo //ContestNames = cq.Contests.Where(x => x.ContestName.Contains("cqww")).Select(x => x.ContestName).ToList(), //return all contests in Db table ordered by name ContestNames = (from cn in ContestQ select new ContestNamestype { key = cn.ContestId, value = cn.ContestName }).ToList(), //return all WPX contests in Db table ordered by name //ContestNames = ContestQ.SelectMany(x => x.Contests).Where(x => x.ContestName.StartsWith("Cqwpx")).OrderBy(x => x.ContestName).Select(x => x.ContestName).ToList(), //return all contests in Db table RadioNames = (from cn in RadioQ select new RadioNamestype { key = cn.QsoRadioTypeEnum, value = cn.QsoRadioTypeName }).ToList(), Disabled = lc.Disabled, }).ToList(); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_URF_Queryable_DataCallInfoDto_Include_StationCallInfoContestType_Return_DataCallInfoDto exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(DataCallInfoDtos); Assert.IsInstanceOfType(DataCallInfoDtos, typeof(List<DataCallInfoDto>)); Assert.AreEqual(3, DataCallInfoDtos.Count ); Assert.IsNotNull(DataCallInfoDtos[0].StationNames); Assert.IsNotNull(DataCallInfoDtos[0].ContestNames); Assert.IsTrue(DataCallInfoDtos[0].ContestNames.Count > 0); Assert.IsTrue(DataCallInfoDtos[0].StationNames.Count >= 0); //some entry ategories do not have STN defined (singleOp) } }
public async Task Integration_LogDataContext_LogService_Log_await_GetDataCallInfoSelectionsAsync_Return_DataCalls() { bool caught = false; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWork); //Task<DataCalls> DataCalls = null; DataCalls DataCalls = null; string SelectedCall= "CN2R"; var logService = new LogService(_logRepository); try { dataCallObjDTO dataCallObjDTO = new Dto.LogData.dataCallObjDTO() { ControlCategorySettingsDto = new ControlCategorySettingsDto() { CatAssisted = Enum.GetName( typeof(CatAssistedEnum), CatAssistedEnum.ASSISTED ).Replace('_','-'), CatBand = Enum.GetName( typeof(CatBandEnum), CatBandEnum.ALL ), CatNoOfTx = Enum.GetName( typeof(CatNoOfTxEnum), CatNoOfTxEnum.TWO ), CatOperator = Enum.GetName(typeof(CatOperatorEnum), CatOperatorEnum.MULTI_OP).Replace('_', '-'), CatPower = Enum.GetName( typeof(CatPowerEnum), CatPowerEnum.HIGH ), CatOperatorOverlay = Enum.GetName( typeof(CatOperatorOverlayEnum), CatOperatorOverlayEnum.NONE ) }, DataCallInfoDto = new DataCallInfoDto() { CallGroup = CallGroupEnum.CALL1, SelectedCall = SelectedCall, SelectedContestName = "Cqww Ssb 2002" }, CallTab = "C" }; DataCalls = await logService.GetCategorizedCallsAsync(dataCallObjDTO, "default"); //GetCategorizedCallsAsync() is async method of Logservice. //awaut on logService.GetCategorizedCallsAsync() runs asynchronously //converts return type Task<DataCalls> to DataCalls //it will return a DataCalls Assert.IsNotNull(DataCalls); Assert.IsInstanceOfType(DataCalls, typeof(DataCalls) ); Assert.AreEqual(CallGroupEnum.CALL1, DataCalls.CallGroup ); Assert.AreEqual( "C", DataCalls.SelectedCall ); Assert.IsInstanceOfType(DataCalls.Calls, typeof(ICollection<CallGroupCall>)); Assert.AreNotEqual(0, DataCalls.Calls.Count() ); Assert.AreEqual( SelectedCall.Substring(0,1), DataCalls.Calls.ElementAt(0).Call.Substring(0,1) ); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogService_Log_await_GetDataCallInfoSelectionsAsync_Return_DataCalls exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception } }
[TestMethod] //task is required for async TestMerhod return type. return type of void not supported public async Task Integration_LogDataContext_LogService_Log_await_GetDataCallInfoSelectionsAsync_Return_DataCallInfoDto() { bool caught = false; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB 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.GetDataCallInfoSelectionsAsync("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(Dtos[0].SelectedCall, string.Empty); 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 } }
public void Integration_LogDataContext_LogResository_Log_GetContestLogs_Return_LogPageDTO() { using (IDataContextAsync context = new ContestqsoDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWork); LogPageDTO LogPageDTO = null; try { LogCtlDataSettingsDto LogCtlDataSettingsDto = new Dto.LogData.LogCtlDataSettingsDto() { ControlSettingsDto = new ControlSettingsDto() { ControlCategorySettingsDto = new Dto.LogControl.ControlCategorySettingsDto() { CatAssisted = "ALL", CatBand = "ALL", CatNoOfTx = "ALL", CatOperator = "ALL", CatOperatorOverlay = null, CatPower = "ALL", Disabled = false }, ControlFiltersSettingsDto = new Dto.LogControl.ControlFiltersSettingsDto() { Disabled = false, FiltBand = "ALL", FiltContinent = "ALL", FiltCountryInnerHTML = new CountryPrefixtype { key = 8, value = "ALL -" }, FiltCQZone = "ALL", }, ControlXaxisSettingsDto = new Dto.LogControl.ControlXaxisSettingsDto() { XaxisDuration = "48", XaxisStarttime = "00:00z Day1", XaxisStarttimeIndex = 0 }, ControlYaxisSettingsDto = new Dto.LogControl.ControlYaxisSettingsDto() { YaxisFunction = "QSO Rate", YaxisFunctionIndex = 0, YaxisInterval = "60", YaxisViewType = "Column", } }, DataCallInfoDtos = new DataCallInfoDto[] { new DataCallInfoDto() { CallGroup = CallGroupEnum.CALL1, Disabled = false, LogId = 1, QsoRadioType = QsoRadioTypeEnum.R1, SelectedCall = "CN2R", SelectedContestName = "Cqww Ssb 2002", SelectedStationName = "STN1" }, new DataCallInfoDto() { CallGroup = CallGroupEnum.CALL2, Disabled = false, LogId= 2, QsoRadioType = QsoRadioTypeEnum.R2, SelectedCall = "CN3A", SelectedContestName = "Cqww Ssb 2002", SelectedStationName = "STN2" }, new DataCallInfoDto() { CallGroup = CallGroupEnum.CALL3, Disabled = false, LogId=3, QsoRadioType = QsoRadioTypeEnum.R1, SelectedCall = "CN2AA", SelectedContestName = "Cqww Ssb 2002", SelectedStationName = null, }, }, LogPageRequestDTO = new LogPageRequestDTO() { sidx = "", sord = "asc", page = 1, rows = 16, _search = false } }; string username = "******"; LogPageDTO = _logRepository.GetContestLogs(LogCtlDataSettingsDto, username).Result; //TestContext.WriteLine("Integration_LogDataContext_LogRepository_Query_Log_Include_LogCategory_Return_LogCategorie_Qsoes_Stations_Callsign exception"); //LogforId1s = Logtask as List<Log>; } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogResository_Log_GetContestLogs_Return_LogPageDTO exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception } }
public void Integration_LogDataContext_LogRepository_Query_Log_Include_LogCategory_Return_LogCategory_Qsoes_Stations_CallSign() { //List<Logqso.mvc.Entities.LogDataEntity.Log> LogforId1s = null; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Log> _logRepository = new Repository<Log>(context, unitOfWork); Log Logtask = null; try { Logtask = _logRepository.Query(x => x.LogId == 1) .Include(x => x.Qsoes).Include(x=>x.Stations).Include(x=>x.LogCategory).Include(x=>x.CallSign) .Select() .SingleOrDefault(); //TestContext.WriteLine("Integration_LogDataContext_LogRepository_Query_Log_Include_LogCategory_Return_LogCategorie_Qsoes_Stations_Callsign exception"); //LogforId1s = Logtask as List<Log>; } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogRepository_Query_Log_Include_LogCategory_Return_LogCategorie_Qsoes_Stations_Callsign exception {0}", ex.Message)); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(Logtask); Assert.IsInstanceOfType(Logtask, typeof(Logqso.mvc.Entities.LogDataEntity.Log)); Assert.AreEqual(LogId, Logtask.LogId ); Assert.IsInstanceOfType(Logtask.ContestYear, typeof(DateTime)); Assert.AreEqual(1, Logtask.CallsignId ); Assert.IsNotNull(Logtask.LogCategory); Assert.AreEqual(Logtask.LogCategory.CatBandEnum, (int)Logqso.mvc.common.Enum.CatBandEnum.ALL); Assert.IsNotNull(Logtask.Qsoes); Assert.AreEqual(2, Logtask.Qsoes.Count ); Assert.IsNotNull(Logtask.Stations); Assert.AreEqual(4, Logtask.Stations.Count ); Assert.IsNotNull(Logtask.CallSign); Assert.AreEqual( "CN2R", Logtask.CallSign.Call ); } }