|
using System.IO;
FileInfo info = new FileInfo("filename.txt");
long charCount = info.Length;
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
After spending the last few months reading about Test Driven Development I am a complete and utter believer. Unfortunately I'm still inexperienced and need advice on unit testing a class which incorporates a timer.
For example I am building an ActivityMonitor class which would be used to detect an activity timeout on a class (typically a mediator for a windows form) and reset it. I'm envisioning something like this:
ActivityMonitor
..private Timer _timer;
..private EventDelegate _timeout_callback;
..ActivityMonitor(EventDelegate callback, int timer_interval);
..public Reset();
How do I test something like TimeoutRaisesCallback? I could set the timer of course and wait for the callback but that would just slow down my unit tests. Do I merely set it to something very short like a few milliseconds and take the hit? Or is there a better standard way to handle this?
Also, suppose I have a class that uses the Activity Monitor:
ClassThatUsesActivityMonitor
..private ActivityMonitor _activity_monitor;
..ClassThatUsesActivityMonitor() {_activity_monitor = new ActivityMonitor(new EventDelegate(Reset));}
..public Reset();
..public DoSomething();
How do I go about unit testing that ClassThatUsesActivityMonitor reacts appropriately if the ActivityMonitor calls its Reset() function while DoSomething() is executing?
I look foreward to your responses, thank you very much,
Togakangaroo
|
|
|
|
|
umm...bump...not sure why I'm not getting a response
|
|
|
|
|
I doing the work on the C#.net 2005 Windows Application. In Windows Application their is control named web browser which is i used.
I want to get another data(Value) in the web browser where a data(Value) is already in it.i want to change the data(Value) dynamically(I mean update the webbrowser according to the click happend in the data grid view)? how can i done this? Please help me.
MURALEEKRISHNAN.K
|
|
|
|
|
This question didn't make sense last time you asked it. Did you bother to read the replies you got ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
so that i make clear the question which is i asked
MURALEEKRISHNAN.K
|
|
|
|
|
ItIf you have a datagrid, you have an ASP.NET website. This will run inside your web browser, how do you want to interact with it, in code ? You want to insert values ? OK, in that case, you need to access the HTML of the current page, parse it and modify it.
I found this with google:
http://bytes.com/forum/thread254118.html[^]
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I am writing a web app where I have a staff heirarchy, coaches, business manager, ect.
I have an area where you fill in contact information for these people, along with parents and any other contacts you may have.
I want to be able to have a button on one page that says "Choose Coach" for example, and it brings up the list of people I entered, lets me select one, and then save it.
I can do all the selecting and saving side of it. I don't know how to have that page come up and then page it back to the parent page.
I am using ASP.NET. Any ideas?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
so you didn't notice our ASP.NET forum ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi there.
How can we collapse a node in treeView (WinForm) ?
Thank you.
|
|
|
|
|
Hi,
Please try this code snippet:
void CollapseTree(TreeNode ParentNode)
{
if(ParentNode.IsExpanded)
ParentNode.Toggle();
for(int i=ParentNode.Nodes.Count-1;i>=0;i--)
{
if(ParentNode.Nodes[i].Nodes.Count>0)
{
if(ParentNode.Nodes[i].IsExpanded)
ParentNode.Nodes[i].Toggle();
CollapseTree(ParentNode.Nodes[i])
}
}
}
For more details please visit the following link:
Article1[^]
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
So you used Toggle() method.
Thank you
|
|
|
|
|
Hello
1-i have a method of weather web service, but i do not know how using it in my client windows form.
URL:http://www.deeptraining.com/webservices/weather.asmx
2-I have a C# code about weather web service,but i do not know how using it in my server for making web service.
URL:http://barnamenevis.org/forum/showthread.php?t=47550&highlight=%D9%87%D9%88%D8%A7
thanks
|
|
|
|
|
Hello.
Well,here[^] there are many useful posts.
Why don't you use them ?
|
|
|
|
|
hello
I know them,but i do not know how using them.
I want help about them.
thank you
|
|
|
|
|
Hi there.
I have a code like this :
Regex.IsMatch("sth", textBoxSearchTxt.Text.Trim(), RegexOptions.IgnoreCase)
Thus I must extrude ESCAPE CHARACTERS from textBoxSearchTxt.Text
How can I do this by C#
As always thanks in advance.
modified on Monday, August 11, 2008 8:28 PM
|
|
|
|
|
Mohammad Dayyan wrote: Thus I must extrude ESCAPE CHARACTERS from textBoxSearchTxt.Text ( Like + * ( ) ... )
I am confused, + * ()... are not escape chars? what are you trying to exclude none alpha chars?
this RegEx will remove all except alpha-numeric.
string newString = Regex.Replace(oldString, "[^A-Za-z0-9]", "");
Yusuf
|
|
|
|
|
Oh, I'm sorry.
I mistook.
Yusuf wrote: string newString = Regex.Replace(oldString, "[^A-Za-z0-9]", "");
Thank you.
|
|
|
|
|
How do I get the current Date and Time in .NET fw.
Please let me know.
Thanks,
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
Is this your purpose?
DateTime time = DateTime.Now;
Console.WriteLine(time);
Console.ReadKey();
|
|
|
|
|
You use DateTime.Now to get the current date and time on the local machine.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
use the above code and add a timer object so that you can refresh your clock ok? choose timer tick event and add the code to it.
nelsonpaixao@yahoo.com.br
|
|
|
|
|
Hello,
I was trying to load data from xml files to SQL Server tables.
I am using XMLTextReader to read from the files. my code's working and loading information to two tables. Except, few fields.
They show no values when read - even though the file contains values for them.
I notice all of them are either unsignedByte or unsignedInt type in the xml schema.
I changed them to strings just to test, but it's doing the same.
I think the datatype is not making any difference, but these elements don't have any attributes and the values are directly in the tags.
So, could be I'm missing something. Here's part of my code:
while (reader.Read())
{ switch (reader.NodeType)
{ case XmlNodeType.Element:
if (reader.Name.ToLower().Equals("decimals"))
{ dec = reader.Value; }
..... break;
case XmlNodeType.Text:
...nothing break;
case XmlNodeType.EndElement:
break;
}
}
Any idea, what's wrong?
Thanks.
|
|
|
|
|
Did you step through your code to see what's happening ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Yes i did. I even used the reader.HasValue property and it's coming up with false.
For some reason, it's not recognizing there's any value - when I do have values.
|
|
|
|