private NSContext GetNSContext() { var nsContext = new NSContext(_ConnectionString); nsContext.Database.Log = DBLogger.Log; return(nsContext); }
public async Task TestCreateProject() { var rowsEffected = 0; var testProj = new Project { ProjectName = "Unit Test Project", SummaryLocation = @"C:\Users\Raul Martinez\Desktop\Output\", }; var scans = new List <Scan> { new Scan { TargetUrl = @"http://aspnet.testsparker.com/", ExportPath = @"C:\Users\Raul Martinez\Desktop\Output\Scan0", Status = ScanStatus.Pending, }, new Scan { TargetUrl = @"http://php.testsparker.com/", ExportPath = @"C:\Users\Raul Martinez\Desktop\Output\Scan1", Status = ScanStatus.Pending, }, new Scan { TargetUrl = @"http://aspnet.testsparker.com/", ExportPath = @"C:\Users\Raul Martinez\Desktop\Output\Scan2", Status = ScanStatus.Pending, }, new Scan { TargetUrl = @"http://php.testsparker.com/", ExportPath = @"C:\Users\Raul Martinez\Desktop\Output\Scan3", Status = ScanStatus.Pending, }, }; using (var db = new NSContext(_ConnectionString)) { testProj.CreatedById = db.Members.FirstOrDefault().Id; db.Projects.Add(testProj); rowsEffected += db.SaveChanges(); scans = scans.Select(x => { x.ProjectId = testProj.Id; return(x); }).ToList(); db.Scans.AddRange(scans); rowsEffected += await db.SaveChangesAsync(); Debug.Assert(rowsEffected > 0); } }
public async Task TestExecuteScan() { var successfulScans = 0; Project testProj = null; List <Scan> scans = null; using (var db = new NSContext(_ConnectionString)) { testProj = db.Projects.FirstOrDefault(); scans = db.Scans.Where(x => x.ProjectId == testProj.Id).ToList(); } Debug.Assert(testProj != null); Debug.Assert(scans != null); foreach (var scan in scans) { var procScan = new NSProcess(scan, testProj, EntityService.GetNodeInstance()); var result = await procScan.ExecuteScanAsync(); } Debug.Assert(successfulScans == scans.Count()); }