public static WhenStatement GetCurrentUserRequestIsSend(this WhenStatement whenStatement, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Getting current user", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.GetMe(session); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var currentUser = response.Map <TestUserModel>(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got user {currentUser}", whenStatement.GetType().Name); whenStatement.AddResultData(currentUser, BddKeyConstants.CurrentUserResponse + testKey); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find current user in response", whenStatement.GetType().Name); } return(whenStatement); }
public static WhenStatement GetAllTimeSeriesRequestIsSend(this WhenStatement whenStatement, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Getting all user time-series", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.GetAllTimeSeries(session); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var createdTimeSeries = response.Map <List <TestTimeSeriesMetadataModel> >(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got time-series {createdTimeSeries}", whenStatement.GetType().Name); whenStatement.AddResultData(createdTimeSeries, BddKeyConstants.UserTimeSeries + testKey); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find list of time-series in response", whenStatement.GetType().Name); } return(whenStatement); }
public static WhenStatement CreateUserRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var userModel = whenStatement.GetGivenData <TestUserModel>(testKey); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Creating user {userModel}", whenStatement.GetType().Name); var response = _facade.PostCreateNewProfile(userModel); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var createdUser = response.Map <TestUserModel>(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got new user {createdUser}", whenStatement.GetType().Name); whenStatement.AddResultData(createdUser, BddKeyConstants.CreatedUserResponse + testKey); } catch (Exception e) { whenStatement.GetStatementLogger() .Warning($"[{{ContextStatement}}] {e}", whenStatement.GetType().Name); } return(whenStatement); }
private static TestTimeSeriesMetadataModel GetTimeSeriesFromDatas(this WhenStatement whenStatement, string testKey = null) { try { return(whenStatement.GetResultData <TestTimeSeriesMetadataModel>(BddKeyConstants.CreatedTimeSeries + testKey)); } catch (Exception e) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find time-series in response data", whenStatement.GetType().Name); } try { return(whenStatement.GetResultData <TestTimeSeriesMetadataModel>(BddKeyConstants.LastHttpResponse + testKey)); } catch (Exception e) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find time-series in last response data", whenStatement.GetType().Name); throw; } }
public static WhenStatement GetTimeSeriesMetadataByIdRequestIsSend(this WhenStatement whenStatement, string timeSeriesId, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Getting user time-series by id", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.GetTimeSeriesMetadataById(session, timeSeriesId); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var timeSeries = response.Map <TestTimeSeriesMetadataModel>(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got time-series {timeSeries}", whenStatement.GetType().Name); whenStatement.AddResultData(timeSeries, BddKeyConstants.UserTimeSeriesById + testKey); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find time-series in response", whenStatement.GetType().Name); } return(whenStatement); }
public static WhenStatement CreateNewTimeSeriesRequestIsSend(this WhenStatement whenStatement, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Creating new time-series", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var newTimeSeries = whenStatement.GetGivenData <TestTimeSeriesMetadataModel>(BddKeyConstants.TimeSeriesToCreate + testKey); var response = _facade.PostCreateTimeSeries(session, newTimeSeries); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var createdTimeSeries = response.Map <TestTimeSeriesMetadataModel>(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got time-series {createdTimeSeries}", whenStatement.GetType().Name); newTimeSeries.Id = createdTimeSeries.Id; newTimeSeries.InfluxId = createdTimeSeries.InfluxId; newTimeSeries.UserId = createdTimeSeries.UserId; whenStatement.AddResultData(createdTimeSeries, BddKeyConstants.CreatedTimeSeries + testKey); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find new time-series in response", whenStatement.GetType().Name); } return(whenStatement); }
public static WhenStatement LoginRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var loginCredentials = whenStatement.GetGivenData <TestLoginModel>(testKey); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Logging in with {loginCredentials}", whenStatement.GetType().Name); var response = _facade.PostLogin(loginCredentials); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); try { var session = response.GetTokenFromResponse(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got session {session}", whenStatement.GetType().Name); whenStatement.AddResultData(session, BddKeyConstants.SessionTokenKey + testKey); } catch (Exception e) { whenStatement.GetStatementLogger() .Warning($"[{{ContextStatement}}] {e}", whenStatement.GetType().Name); } return(whenStatement); }
public static WhenStatement WithSuccess(this WhenStatement whenStatement) { whenStatement.GetStatementLogger() .Information("[{{ContextStatement}}] Expecting last response to have 2XX code", whenStatement.GetType().Name); whenStatement.GetResultData <HttpResponseMessage>(BddKeyConstants.LastHttpResponse).AssertSuccess(); return(whenStatement); }
public static WhenStatement WithCode(this WhenStatement whenStatement, HttpStatusCode code) { whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Expecting last response to have code '{code}'", whenStatement.GetType().Name); whenStatement.GetResultData <HttpResponseMessage>(BddKeyConstants.LastHttpResponse).AssertError(code); return(whenStatement); }
public static WhenStatement LogoutRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var session = whenStatement.GetSessionFromData(testKey); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Closing session '{session}'", whenStatement.GetType().Name); var response = _facade.PostLogout(session); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public static WhenStatement DeleteApiKeyRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var apiKey = whenStatement.GetGivenData <string>(BddKeyConstants.ApiKeyToRemove + testKey); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Removing api key '{apiKey}'", whenStatement.GetType().Name); var response = _facade.DeleteApiKey(whenStatement.GetSessionFromData(testKey), apiKey); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse); return(whenStatement); }
public static WhenStatement UpdateUserRequestIsSend(this WhenStatement whenStatement, TestUserUpdateModel updateModel, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Getting current user", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.PostUpdateProfileNames(session, updateModel); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public void Visit(WhenStatement statement) { var args = VisitChild(statement.Expression); var ifExpression = new CodeConditionStatement(); ifExpression.Condition = args.Expression; var trueExpression = ProcessBinary(statement.Statements, CodeBinaryOperatorType.BooleanAnd); ifExpression.TrueStatements.Add(new CodeMethodReturnStatement(trueExpression)); _codeStack.Peek().Statements.Add(ifExpression); }
public static WhenStatement RemoveTimeSeriesRequestIsSend(this WhenStatement whenStatement, string timeSeriesId, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Removing time-series", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.DeleteTimeSeriesById(session, timeSeriesId); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public static WhenStatement UploadTimeSeriesDataRequestIsSend(this WhenStatement whenStatement, string fileContent, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Uploading .csv data to time-series", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var newTimeSeries = whenStatement.GetTimeSeriesFromDatas(testKey); var response = _facade.PostUploadTimeSeries(session, newTimeSeries.Id, fileContent); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public static WhenStatement CreateNewApiKeyRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var apiKey = whenStatement.GetGivenData <TestUserApiKeyJsonEntity>(BddKeyConstants.NewApiKey + testKey); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Creating new api key '{apiKey}'", whenStatement.GetType().Name); var response = _facade.PostApiKeys(whenStatement.GetSessionFromData(testKey), apiKey); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse); return(whenStatement); }
public static WhenStatement UpdateGivenUpdateTimeSeriesIdsFromModel(this WhenStatement whenStatement, TestTimeSeriesMetadataModel model, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Updating time-series update params Ids", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var timeSeries = whenStatement.GetGivenData <TestTimeSeriesMetadataModel>(BddKeyConstants.TimeSeriesToUpdate + testKey); timeSeries.Id = model.Id; timeSeries.InfluxId = model.InfluxId; timeSeries.UserId = model.UserId; return(whenStatement); }
public static WhenStatement UpdateTimeSeriesRequestIsSend(this WhenStatement whenStatement, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Updating time-series", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var timeSeries = whenStatement.GetGivenData <TestTimeSeriesMetadataModel>(BddKeyConstants.TimeSeriesToUpdate + testKey); var response = _facade.PostUpdateTimeSeries(session, timeSeries.Id, timeSeries); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public override void Accept(GivenStatement switchStmt) { foreach (AstNode node in switchStmt.WhenStatements.Children) { WhenStatement caseStmt = node as WhenStatement; caseStmt.Values.Visit(this); caseStmt.Body.Visit(this); } switchStmt.GivenValue.Visit(this); methodBuilder.EmitInstruction(switchStmt.Location, Opcode.SwitchLookup, switchStmt.WhenStatements.Children.Count); IodineLabel endLabel = methodBuilder.CreateLabel(); methodBuilder.EmitInstruction(switchStmt.Location, Opcode.JumpIfTrue, endLabel); switchStmt.DefaultStatement.Visit(this); methodBuilder.MarkLabelPosition(endLabel); }
public static string GetSessionFromData(this WhenStatement whenStatement, string testKey = null) { string session; try { session = whenStatement.GetResultData <string>(BddKeyConstants.SessionTokenKey + testKey); return(session); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find user session in 'When' data, looking in 'Given'", whenStatement.GetType().Name); } try { session = whenStatement.GetGivenData <string>(BddKeyConstants.SessionTokenKey + testKey); return(session); } catch { whenStatement.GetStatementLogger() .Information( "[{ContextStatement}] Could not find user session in 'Given' data, looking in last response data", whenStatement.GetType().Name); } try { session = whenStatement.GetResultData <HttpResponseMessage>(BddKeyConstants.LastHttpResponse + testKey) .GetTokenFromResponse(); return(session); } catch (Exception e) { whenStatement.GetStatementLogger() .Information( "[{ContextStatement}] Could not find user session in 'LastResponse' data, terminating", whenStatement.GetType().Name); } throw new KeyNotFoundException( "Could not find user session. Probably you should login as a user or provide session itself"); }
/// <summary> /// Initializes a new instance of the CatchStatement class. /// </summary> /// <param name="tokens">The list of tokens that form the statement.</param> /// <param name="tryStatement">The try-statement that this catch-statement is attached to.</param> /// <param name="classExpression">The inner expression.</param> /// <param name="embeddedStatement">The statement embedded within the catch-statement.</param> /// <param name="whenStatement">The when statement.</param> internal CatchStatement(CsTokenList tokens, TryStatement tryStatement, Expression classExpression, BlockStatement embeddedStatement, WhenStatement whenStatement) : base(StatementType.Catch, tokens) { Param.AssertNotNull(tokens, "tokens"); Param.AssertNotNull(tryStatement, "tryStatement"); Param.Ignore(classExpression); Param.AssertNotNull(embeddedStatement, "embeddedStatement"); Param.Ignore(whenStatement); // When statement can be null and not found for a try catch. this.tryStatement = tryStatement; this.catchExpression = classExpression; this.embeddedStatement = embeddedStatement; this.whenStatement = whenStatement; if (classExpression != null) { this.AddExpression(classExpression); if (classExpression != null) { if (classExpression.ExpressionType == ExpressionType.Literal) { this.classType = ((LiteralExpression)classExpression).Token as TypeToken; } else if (classExpression.ExpressionType == ExpressionType.VariableDeclaration) { VariableDeclarationExpression variableDeclaration = (VariableDeclarationExpression)classExpression; this.classType = variableDeclaration.Type; foreach (VariableDeclaratorExpression declarator in variableDeclaration.Declarators) { this.identifier = declarator.Identifier; break; } } } } if (whenStatement != null) { this.AddStatement(whenStatement); } this.AddStatement(embeddedStatement); }
/// <summary> /// Initializes a new instance of the CatchStatement class. /// </summary> /// <param name="tokens">The list of tokens that form the statement.</param> /// <param name="tryStatement">The try-statement that this catch-statement is attached to.</param> /// <param name="classExpression">The inner expression.</param> /// <param name="embeddedStatement">The statement embedded within the catch-statement.</param> /// <param name="whenStatement">The when statement.</param> internal CatchStatement(CsTokenList tokens, TryStatement tryStatement, Expression classExpression, BlockStatement embeddedStatement, WhenStatement whenStatement) : base(StatementType.Catch, tokens) { Param.AssertNotNull(tokens, "tokens"); Param.AssertNotNull(tryStatement, "tryStatement"); Param.Ignore(classExpression); Param.AssertNotNull(embeddedStatement, "embeddedStatement"); Param.Ignore(whenStatement); // When statement can be null and not found for a try catch. this.tryStatement = tryStatement; this.catchExpression = classExpression; this.embeddedStatement = embeddedStatement; this.whenStatement = whenStatement; if (classExpression != null) { this.AddExpression(classExpression); if (classExpression != null) { if (classExpression.ExpressionType == ExpressionType.Literal) { this.classType = ((LiteralExpression)classExpression).Token as TypeToken; } else if (classExpression.ExpressionType == ExpressionType.VariableDeclaration) { VariableDeclarationExpression variableDeclaration = (VariableDeclarationExpression)classExpression; this.classType = variableDeclaration.Type; foreach (VariableDeclaratorExpression declarator in variableDeclaration.Declarators) { this.identifier = declarator.Identifier; break; } } } } this.AddStatement(embeddedStatement); }
public static WhenStatement GetApiKeysRequestIsSend(this WhenStatement whenStatement, string testKey = null) { var response = _facade.GetApiKeys(whenStatement.GetSessionFromData(testKey)); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse); try { var apiKeys = response.Map <TestApiKeysList>(); whenStatement.GetStatementLogger() .Information($"[{{ContextStatement}}] Got api keys {apiKeys}", whenStatement.GetType().Name); whenStatement.AddResultData(apiKeys, BddKeyConstants.UserApiKeys + testKey); } catch { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Could not find api keys in response", whenStatement.GetType().Name); } return(whenStatement); }
public virtual void Accept(WhenStatement caseStmt) { }
public override void Accept(WhenStatement caseStmt) { errorLog.AddError(ErrorType.ParserError, caseStmt.Location, "Statement not allowed outside function body!"); }
public override void Accept(WhenStatement caseStmt) { caseStmt.VisitChildren(this); }
public void Visit(WhenStatement statement, CommonTree tree) { Parent(tree).Children.Add(statement); VisitChildren(tree); }
public override void Accept(WhenStatement caseStmt) { errorLog.AddError(ErrorType.ParserError, caseStmt.Location, "statement can not exist inside pattern!"); }
public override void Accept(WhenStatement caseStmt) { }