As if you didn't know, I am a fan of TDD (Test Driven Development). I try to work in a TDD manner as much as possible.
Unit testing for Windows Mobile applications has always been somewhat challenging. Visual Studio 2008 (professional and above) allows me to work in a TDD manner as I build software for the Windows Mobile platform.
I have been working on some software that needs the time to be changed as part of the tests. This might not be as simple as you think, but it's not hard as long as you know to set the local time not the system time on the device.
private SYSTEMTIME SetDateTime(DateTime dateTime)
{
SYSTEMTIME st = new SYSTEMTIME();
st.year = (short)dateTime.Year;
st.month = (short)dateTime.Month;
st.day = (short)dateTime.Day;
st.hour = (short)dateTime.Hour;
st.minute = (short)dateTime.Minute;
st.second = (short)dateTime.Second;
st.milliseconds = (short)dateTime.Millisecond;
return st;
}
public struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
[DllImport("coredll.dll", SetLastError=true)]
static extern bool SetLocalTime(ref SYSTEMTIME time);
[TestMethod()]
public void HourIsOne()
{
DateTime savedDT = DateTime.Now;
SYSTEMTIME sysTime = SetDateTime(savedDT);
sysTime.hour = 1;
bool setSuccess = SetLocalTime(ref sysTime);
Assert.IsTrue(setSuccess, "Failed to SetLocalTime");
Assert.AreEqual(1, DateTime.Now.Hour,
"Hour should be 1 after setting it");
sysTime = SetDateTime(savedDT);
SetLocalTime(ref sysTime);
}
Showing posts with label TDD. Show all posts
Showing posts with label TDD. Show all posts
Sunday, May 11, 2008
Friday, August 17, 2007
Dr. Neil's Notes 45
Welcome (back) to Dr. Neil's Notes Show 45
Long time no speak, the podcast is back.
Show Notes:
Travel around the globe
TechEd - Orlando, USA and Gold Coast, Australia
Test Driven Development
Tip for team communication.
A ScreenEdit podcast?
Happy Coding!
Long time no speak, the podcast is back.
Show Notes:
Travel around the globe
TechEd - Orlando, USA and Gold Coast, Australia
Test Driven Development
Tip for team communication.
A ScreenEdit podcast?
Happy Coding!
Tuesday, August 14, 2007
TDD session at TechEd last week
Last week at TechEd Australia I presented a session on Unit Testing and Test Driven Development. Presenting this session raised a dilemma for me.
I have been using Unit Testing, Test First and TDD for eight years now. I have been teaching the benefits of a test first approach for seven years.
Should I assume the attendees coming to this session are already sold on TDD and therefore target the content at some of the issues with TDD and tooling or should I focus on teaching the benefits of TDD to attendees who are not yet TDD believers?
I thought about this and decided that while TDD is becoming popular the attendees coming to this session are most likely to not be practicing TDD and want to learn why they should care about unit testing and TDD.
It was a gamble that seemed to pay off. If you attended my session and were already a believer, I hope you learned something and I apologize that it might not have been what you were expecting.
The majority of the attendees in the TDD presentation were learning about TDD for the first time, and the feedback I received was awesome. Here is a sample of the comments about the session:
Brilliant - got my value for TechEd in a single session (especially as my manager who needed convincing re nunit was sitting with me )
Brilliant. I want to get this presentation delivered to all my developers who couldn't make it to TechEd. We've bought into Unit Testing and we need to get to 100% breakthrough, next up has to be TDD
By far this is my best TechEd experience so far. WE NEED MORE NEIL's IN THIS WORLD. Thank you for giving him a session to WOW us with.
Excellent session - I am now a believer!
Excellent session - well presented, clear and concise with lots of useful items and practices to take away. Best session yet.
For me, this has been the best session so far! Excellent content and an excellent presenter! Fantastic. I would love to learn more about this subject. I am implementing unit testing in my team starting Monday!
Great presentation. Very important way of doing development.
Highlight of the conference for me. 11 out of 10.
Thank you to everyone who attended this session.
Information on the eXtreme .NET book I mentioned in the talk
I have been using Unit Testing, Test First and TDD for eight years now. I have been teaching the benefits of a test first approach for seven years.
Should I assume the attendees coming to this session are already sold on TDD and therefore target the content at some of the issues with TDD and tooling or should I focus on teaching the benefits of TDD to attendees who are not yet TDD believers?
I thought about this and decided that while TDD is becoming popular the attendees coming to this session are most likely to not be practicing TDD and want to learn why they should care about unit testing and TDD.
It was a gamble that seemed to pay off. If you attended my session and were already a believer, I hope you learned something and I apologize that it might not have been what you were expecting.
The majority of the attendees in the TDD presentation were learning about TDD for the first time, and the feedback I received was awesome. Here is a sample of the comments about the session:
Brilliant - got my value for TechEd in a single session (especially as my manager who needed convincing re nunit was sitting with me )
Brilliant. I want to get this presentation delivered to all my developers who couldn't make it to TechEd. We've bought into Unit Testing and we need to get to 100% breakthrough, next up has to be TDD
By far this is my best TechEd experience so far. WE NEED MORE NEIL's IN THIS WORLD. Thank you for giving him a session to WOW us with.
Excellent session - I am now a believer!
Excellent session - well presented, clear and concise with lots of useful items and practices to take away. Best session yet.
For me, this has been the best session so far! Excellent content and an excellent presenter! Fantastic. I would love to learn more about this subject. I am implementing unit testing in my team starting Monday!
Great presentation. Very important way of doing development.
Highlight of the conference for me. 11 out of 10.
Thank you to everyone who attended this session.
Information on the eXtreme .NET book I mentioned in the talk
Subscribe to:
Posts (Atom)