public void AddTestCaseAttachment(DeviceTestSuiteCollectionRun collRun, string fileName, Guid singleDeviceRunId, string testCaseName) { var matchingTestCaseExec = collRun.SingleDeviceTestSuiteRuns .Where(x => x.Id == singleDeviceRunId) .Single().TestCaseExecutions .Where(x => x.TestCase.Id == testCaseName).Single(); var attachment = new TestCase_Attachment() { Description = "TestFailureScreenshot", FilePath = fileName }; matchingTestCaseExec.Attachments.Add(attachment); _ctx.SaveChanges(); }
private DeviceTestSuiteCollectionRun ConvertfromCollectionDTO(NUnitXMLCollectionRunDTO collectionRunDTO) { //var TestSelectionFilter = _mapper.Map<Models.Filter>(collectionRunDTO.TestSelectionFilter); var coll = new DeviceTestSuiteCollectionRun() { Id = collectionRunDTO.Id, Date = collectionRunDTO.Date, MobileAppBuild = collectionRunDTO.MobileAppBuild, TestSelectionQuery = collectionRunDTO.TestSelectionQuery, }; List <SingleDeviceTestSuiteRun> testRuns = new List <SingleDeviceTestSuiteRun>(); foreach (var testRunDTO in collectionRunDTO.SingleDeviceTestRuns) { var testRun = ConvertFromSingleDeviceDTO(testRunDTO, coll); testRuns.Add(testRun); } coll.SingleDeviceTestSuiteRuns = testRuns; return(coll); }
public void AddCollectionRun(DeviceTestSuiteCollectionRun collectionRun) { //MobileBuild(New / Existing) - ID always comes from client - must check for match var existingMobileBuild = _ctx.MobileBuilds .Where(x => x.Id == collectionRun.MobileAppBuild.Id) .Include(x => x.DeviceTestSuiteCollectionRuns) .SingleOrDefault(); if (existingMobileBuild != null) { _ctx.MobileBuilds.Attach(existingMobileBuild); } else { var mobileEntry = _ctx.Entry(collectionRun.MobileAppBuild).State = EntityState.Added; } //DeviceCollectionRun(Always new) _ctx.Entry(collectionRun).State = EntityState.Added; foreach (var singleRun in collectionRun.SingleDeviceTestSuiteRuns) { //SingleDeviceTestRuns (Always new) _ctx.Entry(singleRun).State = EntityState.Added; var foo = singleRun.MobileDevice; //Mobile Device (New/Existing) - ID always from client - must check for match var existingMobileDevice = _ctx.MobileDevices .Where(x => x.Id == singleRun.MobileDevice.Id) .SingleOrDefault(); if (existingMobileDevice != null) { var state = _ctx.Entry(existingMobileDevice).State; _ctx.MobileDevices.Attach(existingMobileDevice); } else { var mobileEntry = _ctx.Entry(singleRun.MobileDevice).State = EntityState.Added; } //Test Case Executions and Test Cases foreach (var tcExecution in singleRun.TestCaseExecutions) { //Test Case Execution (Always new) - nothing to do here? _ctx.Entry(tcExecution).State = EntityState.Added; //Handle any existing Test Cases string existingId = tcExecution.TestCaseId; var existingTestCase = _ctx.TestCases .Where(x => x.Id == existingId) .SingleOrDefault(); if (existingTestCase != null) { var state = _ctx.Entry(existingTestCase).State; _ctx.TestCases.Attach(existingTestCase); } else { var mobileEntry = _ctx.Entry(tcExecution.TestCase).State = EntityState.Added; _ctx.SaveChanges(); } } } _ctx.SaveChanges(); PrintCounts(); }
private SingleDeviceTestSuiteRun ConvertFromSingleDeviceDTO(NUnitDeviceTestRunDTO testRunDTO, DeviceTestSuiteCollectionRun deviceTestSuiteCollectionRun) { var base64 = testRunDTO.NUnitXmlBase64; string nunitXml = EncodingUtilities.DecodeStringFromBase64(base64); NUnitReportSummary nUnitReportSummary = _deserializer.GetNunitReportSummmary(nunitXml); var singleRun = new SingleDeviceTestSuiteRun() { Id = testRunDTO.Id, MobileDevice = testRunDTO.MobileDevice, TestRunReportRaw = nunitXml, DeviceTestSuiteCollectionRun = deviceTestSuiteCollectionRun, }; //TODO: Add Deserialized NUnit Data from "NUnitTestRun testrun" //NUnitTestResult = testrun //Use simple, scaled-down Test Case / Test Case Execution models for now: singleRun.TestCaseExecutions = GetTestCaseDataFromDTO(singleRun, nUnitReportSummary); return(singleRun); }