public object Any(GetRegulators request) { DateTime dtStart = DateTime.UtcNow; _logger.Log(EErrorType.Info, " ****** Call start: GetRegulators"); GetRegulatorsResponse response = new GetRegulatorsResponse(); TransferHeader(request, response); _logger.Log(EErrorType.Info, string.Format("ValidateSession({0})", request.SessionToken)); EErrorCodes valSession = ValidateSession(request.SessionToken); if (valSession == EErrorCodes.Success) { try { var regulators = _dal.GetRegulators();; foreach (var reg in regulators.Regulators) { DTO.RegulatorInfo regulatorInfo = new DTO.RegulatorInfo() { Name = reg.Name, Code = reg.Code, CountryCode = reg.CountryCode }; response.Payload.Regulators.Add(regulatorInfo); } response.Success = true; } catch (Exception ex) { _logger.Log(ex); response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unpexcted error: {0}", ex.Message) }); } } else { response.Success = false; response.Errors.Add(new Error() { Code = valSession, Type = EErrorType.Error, Message = string.Format("Invalid session") }); } DateTime dtEnd = DateTime.UtcNow; _logger.Log(EErrorType.Info, string.Format(" ****** Call end: GetRegulators\tTime: {0}", dtEnd - dtStart)); return(response); }
public void GetRegulators_Success(string name) { RunInitSql(name, "ConnectionStringFilings"); GetRegulators request = PrepareRequest <GetRegulators>(name); GetRegulatorsResponse response = Post <GetRegulators, GetRegulatorsResponse>("GetRegulators", request); RunFinalizeSql(name, "ConnectionStringFilings"); Assert.AreEqual(response.Success, true, "GetRegulators call failed"); Assert.Greater(response.Payload.Regulators.Count, 0, "Empty regulator list returned"); Assert.AreNotEqual(response.Payload.Regulators.FirstOrDefault(i => i.Code == "SEC"), null, "SEC is not present on the list"); }
public void GetRegulators_InvalidSession(string name) { RunInitSql(name, "ConnectionStringFilings"); GetRegulators request = PrepareRequest <GetRegulators>(name); request.SessionToken = Guid.NewGuid().ToString(); GetRegulatorsResponse response = Post <GetRegulators, GetRegulatorsResponse>("GetRegulators", request); RunFinalizeSql(name, "ConnectionStringFilings"); Assert.AreEqual(response.Success, false, "GetRegulators succeeded with invalid session"); Assert.AreEqual(response.Payload.Regulators.Count, 0, "Regulator list is not empty"); Assert.IsNotEmpty(response.Errors, "Errors are empty in the response"); Assert.AreEqual(response.Errors[0].Code, EErrorCodes.InvalidSession, "Incorrect error code returned"); }
public GetRegulatorsResponse PostGetRegulators(GetRegulators request) { var response = Post <GetRegulators, GetRegulatorsResponse> ("GetRegulators", request); return(response); }