public void tstConvertToWords() { NumberToText _obj = new NumberToText(); _obj.noToConvert = 563.9; string s = _obj.getConvertedValue(); s = s.Replace(" ", ""); Assert.AreEqual("FIVEHUNDREDSIXTY-THREEDOLLARSANDNINETYCENTS", s); }
protected void btnConvert_Click(object sender, EventArgs e) { double i; try { if (Page.IsValid) { if (double.TryParse(txtNo.Text, out i)) { i = Math.Round(i, 2); txtNo.Text = i.ToString(); NumberToText _obj = new NumberToText(); _obj.noToConvert = i; lblResult.Text = _obj.getConvertedValue(); } } } catch(System.Exception ex) { //No time to catch error systematically lblResult.Text = ex.ToString(); } }