public void TestErrorHandling() { var data = new ErrorStruct[8]; data[0] = new ErrorStruct("5 + true;", "type mismatch: INTEGER+BOOLEAN"); data[1] = new ErrorStruct("5 + true; 5;", "type mismatch: INTEGER+BOOLEAN"); data[2] = new ErrorStruct("-true;", "Unknown operator: -BOOLEAN"); data[3] = new ErrorStruct("true + false;", "Unknown operator: BOOLEAN+BOOLEAN"); data[4] = new ErrorStruct("77; true + false; 66;", "Unknown operator: BOOLEAN+BOOLEAN"); data[5] = new ErrorStruct("if(10 > 2) {true + true}", "Unknown operator: BOOLEAN+BOOLEAN"); data[6] = new ErrorStruct(@" if (25 > 5) { if (10 > 2) { return true + false; } return 1; } ", "Unknown operator: BOOLEAN+BOOLEAN"); data[7] = new ErrorStruct("foobar", "Identifier not found: foobar"); for (var i = 0; i < data.Length; i++) { var evaluated = TestEval(data[i].Input); if (evaluated.GetType() == typeof(Error)) { Assert.True(evaluated.Message == data[i].Expected); } } }
public ErrorStruct ReplaceRecord(Record user) { ErrorStruct check = CheckRecord(user); if (check == true) { connection.Replace(user); } this.DBUpdated(GetRecords()); return(check); }
public static List <string> GetErrorsFromIntPtr(IntPtr P) { ErrorStruct r = (ErrorStruct)Marshal.PtrToStructure(P, typeof(ErrorStruct)); List <string> Errors = new List <string>(); for (int i = 0; i < r.number_of_messages; i++) { int ErrorLength = Marshal.ReadInt32(r.sizes_uint_array, i); if (ErrorLength > 0) { IntPtr s = Marshal.ReadIntPtr(r.messages_string_array, i); string Error = Marshal.PtrToStringAuto(s); Errors.Add(Error); } } return(Errors); }
public ErrorStruct AddRecord(Record user) { ErrorStruct check = CheckRecord(user); if (check == true) { string salt = RandomString(10); for (int i = 0; i < 1000; ++i) { user.Password += salt; user.Password = GetHashString(user.Password); } user.Password += "(" + salt + ")"; connection.Add(user); } this.DBUpdated(GetRecords()); return(check); }
internal void SubmitException(string itnUserName, ExceptionStruct es, string excString, bool isComment) { IAsyncResult ar = _errorReport.Beginauthorize("eap", itnUserName, null, null); while (!ar.IsCompleted) { if (_needProcessEvents) { Application.DoEvents(); } } string notifierID = _errorReport.Endauthorize(ar); ErrorStruct errs = new ErrorStruct(); errs.errorDate = DateTime.Now; errs.errorDescription = excString; errs.errorNotifierId = notifierID; errs.errorOs = Environment.OSVersion.ToString(); errs.errorAction = ""; ar = _errorReport.BeginpostError(errs, es, isComment, null, null); while (!ar.IsCompleted) { if (_needProcessEvents) { Application.DoEvents(); } } try { _errorReport.EndpostError(ar); } catch (XmlRpcFaultException ex) { if (_needProcessEvents) { MessageBox.Show("Error submitting exception data.\n" + ex.FaultString, "Report Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void IncorrectData(ErrorStruct errStruct) { this.correct = errStruct.Correct; this.Save.IsEnabled = correct; this.FirstNamePopUp.IsOpen = errStruct.IncorrectFirstName; this.SecondNamePopUp.IsOpen = errStruct.IncorrectSecondName; this.SurnamePopUp.IsOpen = errStruct.IncorrectSurname; this.LoginPopUp.IsOpen = errStruct.IncorrectLogin; switch (errStruct.PWStrength) { case ErrorStruct.PassStrength.Low: this.PWStrength.Value = 33; break; case ErrorStruct.PassStrength.Medium: this.PWStrength.Value = 66; break; case ErrorStruct.PassStrength.High: this.PWStrength.Value = 100; break; } }
public IAsyncResult BeginpostError(ErrorStruct errStruct, ExceptionStruct excStruct, bool comment, AsyncCallback callback, object asyncState) { return(BeginInvoke("postError", new object[] { errStruct, excStruct, comment }, this, callback, asyncState)); }
public void postError(ErrorStruct errStruct, ExceptionStruct excStruct, bool comment) { Invoke("postError", new object[] { errStruct, excStruct, comment }); }
public void IncorrectData(ErrorStruct error) { this.editWindow.IncorrectData(error); }