Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
B

BabyOreo

@BabyOreo
About
Posts
16
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • unit testing function
    B BabyOreo

    okay..another question,is it necessary to use assert? when shuold we use assert and when not? for example,how to insert the assert to verify the result? [TestMethod()] public void saverecordTest() { Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value target.txtcode.Text = "19095"; target.txtname.Text = "453427"; target.txtaddress.Text = "s34235"; target.saverecord(); }

    C# testing beta-testing help question

  • unit testing function
    B BabyOreo

    How m i going to unit testing this kind of function? plz help. private void saverecord() { OleDbConnection savecon = new OleDbConnection(constring); OleDbCommand savecom = new OleDbCommand("insert into Employee_Details values (?,?,?)", savecon); OleDbParameter param; param = savecom.Parameters.Add("@empcode", OleDbType.VarChar, 10); param.Value = txtcode.Text; param = savecom.Parameters.Add("@empname", OleDbType.VarChar, 25); param.Value = txtname.Text; param = savecom.Parameters.Add("@empjoin", OleDbType.Date); param.Value = DateTime.Now.ToShortDateString(); savecon.Open(); int rows = savecom.ExecuteNonQuery(); MessageBox.Show(rows.ToString() + "rows affected"); btnref.PerformClick(); savecon.Close(); } [TestMethod()] public void saverecordTest() { Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value target.saverecord(); //Assert.Inconclusive("A method that does not return a value cannot be verified."); }

    C# testing beta-testing help question

  • vsts 2008 unit testing
    B BabyOreo

    How m i going to test this kind of function? private void saverecord() { OleDbConnection savecon = new OleDbConnection(constring); OleDbCommand savecom = new OleDbCommand("insert into Employee_Details values (?,?,?)", savecon); OleDbParameter param; param = savecom.Parameters.Add("@empcode", OleDbType.VarChar, 10); param.Value = txtcode.Text; param = savecom.Parameters.Add("@empname", OleDbType.VarChar, 25); param.Value = txtname.Text; param = savecom.Parameters.Add("@empjoin", OleDbType.Date); param.Value = DateTime.Now.ToShortDateString(); savecon.Open(); int rows = savecom.ExecuteNonQuery(); MessageBox.Show(rows.ToString() + "rows affected"); btnref.PerformClick(); savecon.Close(); } [TestMethod()] public void saverecordTest() { Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value target.saverecord(); //Assert.Inconclusive("A method that does not return a value cannot be verified."); }

    C# testing tutorial beta-testing question

  • Argument
    B BabyOreo

    yes.wan to know how to assign a value to test method.

    C# tutorial question

  • Argument
    B BabyOreo

    what if i wan to test the following function? private void btnAddEntry_Click(object sender, EventArgs e) { double gas, miles; int i; string d; char c; bool validDate; // Validate date format (actual values not checked) // strip out any spaces d = ""; for (i = 0; i < txtDate.Text.Length; i++) { if (txtDate.Text.Substring(i, 1) != " ") { d += txtDate.Text.Substring(i, 1); } } txtDate.Text = d; validDate = true; // make sure date has eight characters (two are slashes remainder are numbers) if (txtDate.Text.Length != 8) { validDate = false; } else { for (i = 0; i < 8; i++) { c = Convert.ToChar(txtDate.Text.Substring(i, 1)); if (i == 2 || i == 5) { if (c != '/') { validDate = false; } } else { if (c < '0' || c > '9') { validDate = false; } } } } if (!validDate) { MessageBox.Show("Date must be in form mm/dd/yy", "Date Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtDate.Focus(); return; } // Make sure miles is greater than previous value miles = Convert.ToDouble(txtMiles.Text); if (numValues > 0) { if (miles <= odometer[numValues - 1]) { MessageBox.Show("Odometer reading less than previous value.", "Odometer Reading Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMiles.Focus(); return; } } // No zero gallons allowed gas = Convert.ToDouble(txtGallons.Text); if (gas <= 0) { MessageBox.Show("Gallons pumped must be greater than zero", "Gallons Pumped Error", MessageBoxButtons.OK, MessageBoxI

    C# tutorial question

  • Argument
    B BabyOreo

    i'm doing vsts2008 unit testing. How m i assign date to following test method? public void btnAddEntry_ClickTest() { frmMileage_Accessor target = new frmMileage_Accessor(); // TODO: Initialize to an appropriate value object sender = null; // TODO: Initialize to an appropriate value EventArgs e = null; // TODO: Initialize to an appropriate value target.btnAddEntry_Click(sender, e); //Assert.Inconclusive("A method that does not return a value cannot be verified."); }

    C# tutorial question

  • Argument
    B BabyOreo

    Can i assign some string or integer to EventArgs? For example, i wan assign value to the following: EventArgs e = null; Anyone can provide some examples? Thanks!

    C# tutorial question

  • C# sample project
    B BabyOreo

    Anyone can provide c# sample project? i need a complicated one for vsts 2008 unit testing. Thanks for help!

    C# csharp testing beta-testing help question

  • vsts 2008 unit testing
    B BabyOreo

    Thanks for previous answer. How about the following? private void btnSave_Click(object sender, EventArgs e) { // Save mileage data int i; sfdFiles.Filter = "Files (*.gas)|*.gas"; sfdFiles.DefaultExt = "gas"; sfdFiles.Title = "Save Mileage File"; if (sfdFiles.ShowDialog() == DialogResult.OK) { StreamWriter sw = new StreamWriter(sfdFiles.FileName); this.Text = "Gas Mileage-" + sfdFiles.FileName; sw.WriteLine(numValues); for (i = 0; i < numValues; i++) { sw.WriteLine(dates[i]); sw.WriteLine(odometer[i]); sw.WriteLine(gallons[i]); } sw.Close(); } } [TestMethod()] public void btnSave_ClickTest() { frmMileage_Accessor target = new frmMileage_Accessor(); // TODO: Initialize to an appropriate value object sender = null; // TODO: Initialize to an appropriate value EventArgs e = null; // TODO: Initialize to an appropriate value target.btnSave_Click(sender, e); //Assert.Inconclusive("A method that does not return a value cannot be verified."); } I should initialize value to EventArgs? I have problem to assign value to EventArgs. How is the correct answer look like?

    C# testing tutorial beta-testing question

  • vsts 2008 unit testing
    B BabyOreo

    Hi, If i want to test on event handler, how can i initialize the value to? fyi,i'm using unit testing features in vsts2008 For example, private void txtDate_KeyPress(object sender, KeyPressEventArgs e) { // Numbers, slash only if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (int) e.KeyChar == 8 || e.KeyChar == '/') { e.Handled = false; } else if ((int) e.KeyChar == 13) { txtMiles.Focus(); } else { e.Handled = true; } } (auto generated when i create unit testing) [Test Method] public void txtDate_KeyPressTest() { frmMileage_Accessor target = new frmMileage_Accessor(); // TODO: Initialize to an appropriate value object sender = null; // TODO: Initialize to an appropriate value KeyPressEventArgs e = null; // TODO: Initialize to an appropriate value target.txtDate_KeyPress(sender, e); }

    modified on Friday, April 24, 2009 3:25 AM

    C# testing tutorial beta-testing question

  • vsts 2008 unit testing
    B BabyOreo

    How to do unit test on private method and event handler? and how to test on method that does not return anything (void)? not using assert? Can someone provide example? Thank you!

    C# testing tutorial beta-testing question

  • How to do unit testing to non-function? [modified]
    B BabyOreo

    How to do unit testing to non-function? I'm using vsts 2008 and i able to create a unit testing for function but i'm not sure how to create for sequential structure code. plz help!

    modified on Tuesday, April 7, 2009 10:16 PM

    C#

  • Sequential structure code
    B BabyOreo

    sequential structure code means no function inside right? thanks for above comments.

    C#

  • Sequential structure code
    B BabyOreo

    How the sequential structure code looked like? Can anyone give me some examples? Thanks!

    C#

  • Why this program run twice before terminate?
    B BabyOreo

    halo.. I want to send email to my account but this program run twice. So,after click on submit button, 2 same mails send to my account.How this could happen? Thanks. <code><small>Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" Catch ex As Exception litStatus.Text = ex.ToString() End Try End Sub

    ASP.NET csharp design question

  • why this program run twice before terminate?
    B BabyOreo

    halo.. I want to send email to my account but this program run twice. So,after click on submit button, 2 same mails send to my account.How this could happen?:confused: Thanks. Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" Catch ex As Exception litStatus.Text = ex.ToString() End Try End Sub End Class

    Visual Basic csharp design question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups