public Triangle(double height, double width) { SimpleValidator.CheckNotPositive((decimal)height, "height"); SimpleValidator.CheckNotPositive((decimal)width, "width"); this.Height = height; this.Width = width; }
public async void SignUp(string email, string password) { try { SimpleValidator.CheckNullOrEmpty(email, "email"); SimpleValidator.CheckNullOrEmpty(password, "password"); } catch (ArgumentException e) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Invalid email or password", e.Message, buttons); return; } if (password.Length < 6) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Password must be at least 6 chars long", "", buttons); return; } // teamelderberry.firebaseapp.com //FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig("AIzaSyCs3jVuwKl9ntdSaJWvGqzAzGoVX7Xblk4")); //try //{ // // TODO: Use auth link to implement storage of some user preferences, like portfolio // var authLink = await authProvider.CreateUserWithEmailAndPasswordAsync(email, password); //} //catch (FirebaseAuthException e) //{ // MessageBoxButtons buttons = MessageBoxButtons.OK; // if (e.Reason.ToString().Equals("EmailExists")) // { // MessageBox.Show("The account already exists", "", buttons); // } // else // { // MessageBox.Show(e.Reason.ToString(), "", buttons); // } // return; //} //// Sign up successful, notify and redirect to main Form //MainForm main = Application.OpenForms["MainForm"] as MainForm; //if (main != null) //{ // main.ShowDialog(); //} //else //{ // new MainForm().ShowDialog(); //} }
public void CanInvalidateSimple() { var simple = new Simple(); MappingConfigurationLoader.LoadConfigurations(); IValidate <Simple> valid = new SimpleValidator(new AutoMapperMappingService()); var result = valid.Check(simple); Assert.False(result.IsValid); }
public override decimal CalculateInterest(int periodInMonths) { SimpleValidator.CheckNotPositive(periodInMonths, "Interest period"); if (this.Balance > 0M && this.Balance < 1000M) { return(0); } return(base.CalculateInterest(periodInMonths)); }
public void CanValidateSimple() { var simple = new Simple { Name = "Fozzy", EmailAddress = "*****@*****.**" }; MappingConfigurationLoader.LoadConfigurations(); IValidate <Simple> valid = new SimpleValidator(new AutoMapperMappingService()); var result = valid.Check(simple); Assert.True(result.IsValid); }
public bool SignIn(string email, string password) { try { SimpleValidator.CheckNullOrEmpty(email, "email"); SimpleValidator.CheckNullOrEmpty(password, "password"); } catch (ArgumentException e) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Invalid email or password", e.Message, buttons); return(false); } if (password.Length < 6) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Password must be at least 6 chars long", "", buttons); return(false); } return(true); //// teamelderberry.firebaseapp.com //FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig("AIzaSyCs3jVuwKl9ntdSaJWvGqzAzGoVX7Xblk4")); //try //{ // // TODO: Figure out what to do with the response // //var authLink = await authProvider.SignInWithEmailAndPasswordAsync(email, password); // return true; //} //catch (FirebaseAuthException e) //{ // MessageBoxButtons buttons = MessageBoxButtons.OK; // MessageBox.Show(e.Reason.ToString(), "", buttons); // return false; //} //// Sign in successful, notify and redirect to main Form //MainForm main = Application.OpenForms["MainForm"] as MainForm; //if (main != null) //{ // main.ShowDialog(); //} //else //{ // new MainForm().ShowDialog(); //} }
public void AddMarks(int[] markGroup) { SimpleValidator.CheckNull(markGroup, "Marks argument"); foreach (var mark in markGroup) { if (mark < 2 || mark > 6) { throw new ArgumentException("Invalid mark for the student"); } marks.Add(mark); } }
public void ValidationMessagesAreCorrectlyTransformed() { var simple = new Simple(); MappingConfigurationLoader.LoadConfigurations(); var validator = new SimpleValidator(new AutoMapperMappingService()); var fluentResults = validator.Validate(simple); var myResults = validator.Check(simple); Assert.Equal(fluentResults.IsValid, myResults.IsValid); foreach (var thing in fluentResults.Errors) { Assert.True(myResults.FailureMessages.Any(fm => fm.Message == thing.ErrorMessage)); } }
public void StartWithEvent(int t, IEnumerable <int> list) { if (OnElapsed == null) { throw new InvalidOperationException("No callback set for the Timer"); } SimpleValidator.CheckNull(list, "Timer list Argument"); ListOfInts = list; while (true) { Thread.Sleep(t); this.OnTimedEvent(); } }
public async Task <ActionResult> CreateSale(AutoSalesViewModel autoSaleObj) { try { var isCustomerValid = SimpleValidator.Validate(autoSaleObj.Customer); var isPaymentValid = SimpleValidator.Validate(autoSaleObj.Payment); if (!(isCustomerValid.IsValid && isPaymentValid.IsValid)) { autoSaleObj.Auto = await _autoDataProcessor.FindAutoAsync(autoSaleObj.Auto.AutoID); autoSaleObj.ListStateNames = Enum.GetValues(typeof(StateNames)).Cast <StateNames>(); return(View("Create", autoSaleObj)); } //store Customer Information int custId = await StoreCustomerInformation(autoSaleObj); //store payment Information int paymentId = 0; if (custId != 0) { paymentId = await StorePaymentInformation(autoSaleObj); } // Store Sales Data if (paymentId != 0) { await StoreSalesData(autoSaleObj, custId, paymentId); } autoSaleObj.ListStateNames = Enum.GetValues(typeof(StateNames)).Cast <StateNames>(); ViewBag.title = "<p>Success</p>"; ViewBag.msg = "<p> Sales completed. </p>"; return(View("Create", autoSaleObj)); } catch (Exception ex) { autoSaleObj.ListStateNames = Enum.GetValues(typeof(StateNames)).Cast <StateNames>(); ViewBag.title = "<p>Error!</p>"; ViewBag.msg = "<p> Please try again later. </p>"; return(View("Create", autoSaleObj)); } }
public void Start(int t, IEnumerable <int> list, PrintDelegate printDel = null) { if (printDel == null) { throw new InvalidOperationException("No callback set for the Timer"); } SimpleValidator.CheckNull(list, "Timer list Argument"); TimerCallback = printDel; ListOfInts = list; Timer aTimer = new Timer(); aTimer.Interval = t; aTimer.Elapsed += OnTimedDelegate; aTimer.AutoReset = true; aTimer.Start(); Console.ReadLine(); }
public void StartWithCallback(int t, ElapsedEventHadler callback) { SimpleValidator.CheckNull(callback, "Timer callback"); OnElapsed = callback; BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (s, e) => { while (true) { Thread.Sleep(t); this.OnTimedEvent(); } }; // bw.RunWorkerCompleted += (s, e) => { this.OnTimedEvent(); }; bw.RunWorkerAsync(); }
public void AddCall(Call call) { SimpleValidator.CheckNull(call, "call"); callHistory.Add(call); }
/// <summary> /// Add equality validator /// </summary> /// <param name="prev"></param> /// <param name="selector"></param> /// <param name="expected"></param> /// <typeparam name="TSource"></typeparam> /// <typeparam name="TTarget"></typeparam> /// <returns></returns> public static SimpleValidator <TSource> AddEquals <TSource, TTarget>(this SimpleValidator <TSource> prev, Func <TSource, TTarget> selector, TTarget expected) { return(prev.Add(source => selector(source).Equals(expected))); }
/// <summary> /// Add equality validator /// </summary> /// <param name="prev"></param> /// <param name="expected"></param> /// <typeparam name="TSource"></typeparam> /// <returns></returns> public static SimpleValidator <TSource> AddEquals <TSource>(this SimpleValidator <TSource> prev, TSource expected) { return(prev.Add(source => source.Equals(expected))); }