|
Hi,
I need your help and suggestions regarding NUnit in asp.net....I am trying to write NUnit test cases for my asp.net application...can anybody suggest me some good practise for writing that..or some good sample codes for that..I started working on that..but it's not going smmothly..specially while saving the data...like that...please help me...
regards
alex.
|
|
|
|
|
To test ASP.NET dependent code, you can use NUnitasp[^]. AFAIK, it's not good like the real NUnit. You can use NUnit itself to test your application, but you won't be able to include ASP.NET dependent code like Server.MapPath or HttpContext.Current etc. But you can test your class libraries and business rules. Also VS team system has some unit testing features, I guess that can be used to test ASP.NET applications.
|
|
|
|
|
exactly..i am planning to test classlibraries..do u have any idea about this...ie, writing test cases for class libraries
|
|
|
|
|
It's pretty straight forward. Have you downloaded NUnit ? Go through the get started section. Basically to get started, you can create a new project in your solution and keep all your test classes inside that. So you can avoid that class when you release your project.
|
|
|
|
|
Ys i already started..but i am stucked how can i write test cases for save functionality....
|
|
|
|
|
Your save function should have a return type, either bool or maybe int. You can assert that correct data passed to the save function will return true (in case of bool, or a 0 for int) and for bad data a return of false (or a specified error code for ints). You could always have a custom return type if you wanted.
|
|
|
|
|
Hello all,
I want to be have a dropdownlist and its item for example is:
10000-20000
20000-30000
30000-40000
I want when i click on one of them,a collection of item comes with the its price range.
how i can do this?
how i should design database for this aim?
please help me,
thank you,
Hoda
|
|
|
|
|
create some tables in your database
(SqlServer: )
Table brackets
Fields
ID (seed, int),
bracketMin (money),
bracketMax (money)
Table Products
Fields
ID (seed, int),
bracketID (int),
Description (nvarchar(50)),
Price (Money)
Queries:
for your dropdown:
SELECT ID, Convert(varchar, bracketMin) + '-' + Convert(varchar, bracketMax)
FROM Brackets
For your gridview to display the prices
SELECT ID, Description, Price
FROM Products
Where bracketID = dropdown.selectedvalue
|
|
|
|
|
good solution, but you dont need to store the bracketId in the products table - and this is a bad idea if you ever change the bracket min/max it might invalidate this value.
<br />
SELECT ID, Description, Price<br />
FROM Products<br />
INNER JOIN brackets ON product.price BETWEEN brackets.bracketMin AND bracket.bracketMax<br />
WHERE bracketID = {dropdown.selectedvalue}
|
|
|
|
|
Dear Friend,
thank you very much for you response.
|
|
|
|
|
hai,
here i am updating 100 records at the same time.
when the update fails, the record is to store in a log file (.txt).
how to implement.?
FOR EXAMPLE.............
try
{
for (i=1;i=5;i++)
{
int a=i;
sqlinsert="update tbl_name set loop_no=a where rollnumber=a";
cmd = new SqlCommand(sqlinsert, conn);
}
}
catch(SqlException ae)
{
strreturn += "<br>Message: " + ae.Message.ToString();
}
How to capture the failure records for the above UPDATE statement?
HELP ME!
i m using ASP.NET with C# (.net 2005, 2.0 framework)
modified on Wednesday, April 16, 2008 8:40 AM
|
|
|
|
|
Hi John Sundar,
In the try block yau have a statement
try
{
cmd.ExecuteNonQuery();
}
Catch(Exception ex)
{
// In the catch block write file streams to write the file and in the file write roll no which not updated.
}
|
|
|
|
|
could u provide me an example senthil? for my QUESTION?
|
|
|
|
|
After You enter
try
{
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
FileStream fs;
StreamWriter sw;
fs = new FileStream("practice.txt", FileMode.Open );
sw = new StreamWriter(fs);
// write a line to the file
//In this line you concatenate the data
string newLine = "Not so different from you and me";
sw.WriteLine(newLine);
// close the streams
sw.Close();
fs.Close();
}
|
|
|
|
|
try
{
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
FileStream fs;
StreamWriter sw;
fs = new FileStream("practice.txt", FileMode.Open );
sw = new StreamWriter(fs);
// write a line to the file
//In this line you concatenate the data
string newLine = "Not so different from you and me";
sw.WriteLine(newLine);
// close the streams
sw.Close();
fs.Close();
}
-----> i dont want to store a single line in the practice.txt. i need to store the record values which is failed (i.e.. 100,200) as mentioned in my example.......
How to achieve it?
thanks in advance
|
|
|
|
|
Whether you are entering the values in the textboxes(Roll No) for updating the records.
|
|
|
|
|
no senthil, i m taking those roll numbers from an excel file and processing.... i will pass the roll number one by one. when it failed, i want to store it........
how to achieve it?
|
|
|
|
|
How will you take from excel file can you send me the code?
|
|
|
|
|
hai,
here i am updating 100 records at the same time.
when the update fails, the record is to store in a log file (.txt).
how to implement.?
FOR EXAMPLE.............
try
{
for (i=1;i=5;i++)
{
int a=i;
sqlinsert="update tbl_name set loop_no=a where rollnumber=a";
cmd = new SqlCommand(sqlinsert, conn);
}
}
catch(SqlException ae)
{
strreturn += "<br>Message: " + ae.Message.ToString();
}
How to capture the failure records for the above UPDATE statement?
HELP ME!
i m using ASP.NET with C# (.net 2005, 2.0 framework)
|
|
|
|
|
Hi,
You can use this logic. I hope that this may help you
int b = 0;
string ew;
for (int i = 0; i <= 5; i++)
{
try
{
if(b==i)
ew=Session["Good"].ToString();
Response.Write("pass" + i);
}
catch
{
Response.Write("Failed" + i);
}
}
Cheers..!
Vijay s
|
|
|
|
|
for (i=1;i=5;i++)
{
int a=i;
sqlinsert="update tbl_name set loop_no=a where rollnumber=a";
cmd = new SqlCommand(sqlinsert, conn);
try
{
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
FileStream fs;
StreamWriter sw;
fs=new Filestream("logfile.txt",FileMode.open);
sw=new StreamWriter(fs);
string newline="Roll No:"+a+"was not updated";
sw.close();
fs.close();
}
}
I think you understand, if you have any doubt ask me.
|
|
|
|
|
once if its go for "CATCH" block, how it can proceed others?
i.e, if record 2 fails, will it proceed other records and complete the whole FOR loop????
i tried.. but getting error...
how to achieve it?
thanks in advance and understanding....
|
|
|
|
|
In my existing project I'm getting this pop up message...
This page contains both secure and nonsecure items. Do you want to display the nonsecure items asp .net c#
But its happening few pages only....whats the exact issue...can somebody tell me...is there any coding (asp .net c#) thru this I can solve it.....
Internet - tool - options----this method doesnt required....
Thnx in advance.
|
|
|
|
|
Mostly it has to do with links in a page. Your page is run in https on the webserver but your link says http. Or you load images in your page with an absolute http path in stead of a relative ~\... path.
|
|
|
|
|
Hi digi..
all images path is such as ../image/........so which one will be better....\
~/image..... or ../image/....
please suggest me asap...
thnx
|
|
|
|