public static async Task <TestRunSessionAgent> StartAsync( ITestRunClientConfiguration configuration, BuildInfo productBuild, string suiteName, int testBuildId, string testBuildNumber, string productLineKey = null, ILogger logger = null, IDictionary <string, ExtraDataValue> extraData = null) { TestRunSessionRequest sessionRequest = new TestRunSessionRequest() { ProductBuild = productBuild, AzureTestBuildId = testBuildId, AzureTestBuildNumber = testBuildNumber, SuiteName = suiteName, StartTime = DateTime.Now, State = TestRunSessionState.NotStarted, ExtraData = extraData, ProductLine = new ProductLine() { Key = productLineKey ?? ExtractBuildName(productBuild) ?? productBuild.AzureBuildDefinitionId.ToString(), AzureProductBuildDefinitionId = productBuild.AzureBuildDefinitionId } }; return(await TestRunSessionAgent.CreateAsync(configuration, sessionRequest, logger)); }
public async Task <IActionResult> Insert(TestRunSessionRequest sessionRequest) { var(sessionResponse, error) = await _service.InsertSessionAsync(sessionRequest); if (!error.IsSuccessful()) { return(error.ToActionResult()); } return(CreatedAtAction(nameof(GetById), new { sessionId = sessionResponse.Id }, sessionResponse)); }
public static void Update(this TestRunSessionRequest request, TestRunSession session) { if (request.ProductLine.Id.HasValue) { session.ProductLineId = request.ProductLine.Id.Value; } session.AzureTestBuildId = request.AzureTestBuildId; session.AzureTestBuildNumber = request.AzureTestBuildNumber; session.SuiteName = request.SuiteName; session.StartTime = request.StartTime; session.FinishTime = request.FinishTime; session.State = request.State; session.ExtraData.UpdateFrom(request.ExtraData); }
public static async Task <TestRunSessionAgent> CreateAsync( ITestRunClientConfiguration configuration, TestRunSessionRequest sessionRequest, ILogger logger = null) { logger = logger ?? new NullLogger(); var client = new TestRunClient(configuration.TestRunServiceUrl); logger.Info("'TestRunClient' created."); var response = await client.InsertSessionAsync(sessionRequest); var productLine = response.ProductLine; logger.Debug("'TestRunSession' inserted: " + ObjToString(response)); return(new TestRunSessionAgent(client, configuration, response, productLine, logger)); }
public static TestRunSession ToDataModel(this TestRunSessionRequest r) { if (r.ProductLine.Id == null) { throw new ArgumentException("`ProductLine.Id` is required."); } return(new TestRunSession() { ProductLineId = r.ProductLine.Id.Value, ProductBuildInfo = r.ProductBuild.ToDataModel(), AzureTestBuildId = r.AzureTestBuildId, AzureTestBuildNumber = r.AzureTestBuildNumber, SuiteName = r.SuiteName, StartTime = r.StartTime, FinishTime = r.FinishTime, State = r.State, TestRuns = r.TestRuns.ConvertAll(tr => tr.ToDataModel()), ExtraData = r.ExtraData.ToDataModel() }); }
public async Task <TestRunSessionResponse> InsertSessionAsync(TestRunSessionRequest session) { return(await SendAsync <TestRunSessionResponse>(HttpMethod.Post, "sessions", session)); }
public async Task <(TestRunSessionResponse, ServiceError)> InsertSessionAsync(TestRunSessionRequest sessionDto) { var build = await _dbService.Query <Data.BuildInfo>(b => b.AzureBuildDefinitionId == sessionDto.ProductBuild.AzureBuildDefinitionId && b.AzureBuildId == sessionDto.ProductBuild.AzureBuildId) .FirstOrDefaultAsync(); if (build == null) { build = sessionDto.ProductBuild.ToDataModel(); _dbService.Add(build); } var(productLine, error) = await _productLineService.GetOrInsertProductLineAsync(sessionDto.ProductLine); if (!error.IsSuccessful()) { return(null, error); } sessionDto.ProductLine = productLine.ToDto(); var session = sessionDto.ToDataModel(); session.ProductBuildInfo = build; _dbService.Add(session); await _dbService.SaveChangesAsync(); var response = session.ToResponse(); response.ProductLine = sessionDto.ProductLine; return(response, ServiceError.NoError); }