| View previous topic :: View next topic |
| Author |
Message |
servotest bob Advanced

Joined: 07 Oct 2005 Posts: 17
|
Posted: Tue Apr 04, 2006 10:30 am Post subject: will mocking mscorlib types ever be supported? |
|
|
| will mocking mscorlib types ever be supported? |
|
| Back to top |
|
 |
scott Moderator

Joined: 09 Jan 2005 Posts: 735
|
Posted: Tue Apr 04, 2006 12:45 pm Post subject: |
|
|
Hi,
It will be supported, but not in the next release that is due next week. _________________ Regards
Scott,
TypeMock Support Group |
|
| Back to top |
|
 |
stephan Newbie

Joined: 30 May 2006 Posts: 3
|
Posted: Tue May 30, 2006 8:37 am Post subject: |
|
|
Hi,
Can you be more precise. When to expect mocking mscorlib types? |
|
| Back to top |
|
 |
richard Moderator

Joined: 09 Jan 2005 Posts: 97
|
Posted: Wed May 31, 2006 12:36 pm Post subject: |
|
|
Hi,
This is still in the works .
What types would you like to mock, perhaps we can mock these first? _________________ Regards
Richard,
TypeMock Support Group |
|
| Back to top |
|
 |
stephan Newbie

Joined: 30 May 2006 Posts: 3
|
Posted: Wed May 31, 2006 12:48 pm Post subject: |
|
|
Thank you for the reply Richard.
I'm trying to mock StreamWriter.
Best Regards
Stephan Zahariev |
|
| Back to top |
|
 |
richard Moderator

Joined: 09 Jan 2005 Posts: 97
|
Posted: Wed May 31, 2006 1:25 pm Post subject: |
|
|
I will add this to our list.
We used the following technique when our tests need to mock Streams.
What we did was to change the file that was being opened and we pointed to another file.
We did this by having a Property with the filename and mocking the property.
e.g. We want to see how we behave with a non existing file
| Code: | private string Filename
{
get { return theFileName; }
}
StreamWriter writer = new StreamWriter(Filename);
// in our tests
mock.ExpectGet("FileName","a_file_that_doesnt_exist');
|
_________________ Regards
Richard,
TypeMock Support Group |
|
| Back to top |
|
 |
stephan Newbie

Joined: 30 May 2006 Posts: 3
|
Posted: Wed May 31, 2006 1:40 pm Post subject: |
|
|
Thanks for the help.
Stephan Zahariev |
|
| Back to top |
|
 |
dagilleland Newbie

Joined: 01 Feb 2006 Posts: 2
|
Posted: Wed Jul 05, 2006 3:41 pm Post subject: |
|
|
| richard wrote: | Hi,
This is still in the works .
What types would you like to mock, perhaps we can mock these first? |
Is it possible to mock the Today property of Date or DateTime?
I've got some tests that have special circumstances for special dates (like range validating when the current date is 1/1/2006), and if I could write mocks to handle those cases, my testing would truly be complete. |
|
| Back to top |
|
 |
ohad Site Admin

Joined: 18 May 2006 Posts: 617
|
Posted: Thu Jul 06, 2006 1:46 pm Post subject: |
|
|
Hi stephan
Unfortunately DateTime is part of the mscorlib
As richard wrote mocking mscorlib is still in the works.
Don't lose your hope!  _________________ Regards
Ohad,
TypeMock Support Group |
|
| Back to top |
|
 |
scott Moderator

Joined: 09 Jan 2005 Posts: 735
|
Posted: Thu Jul 06, 2006 6:06 pm Post subject: |
|
|
although DateTime.Now cannot be mocked there is a workaround.
You can define the following static property in your code.
| Code: | public class DataUtils
{
public static Now
{
get { return DataTime.Now; }
}
} |
This is already very easy to mock _________________ Regards
Scott,
TypeMock Support Group |
|
| Back to top |
|
 |
kenn Newbie

Joined: 19 Nov 2007 Posts: 1
|
Posted: Mon Nov 19, 2007 6:49 am Post subject: |
|
|
Hi Scott,
But does this mean that in the code that I am testing, I will need to use the DataUtils class instead of the DateTime class? If so, that's not very desirable.
Since your post was made over a year ago, has there been a change on whether the mscorlib types be supported for mocking?
Ken |
|
| Back to top |
|
 |
lior Moderator

Joined: 28 Sep 2006 Posts: 305
|
Posted: Mon Nov 19, 2007 11:33 am Post subject: |
|
|
Ken hi,
So far there has not been any progress on this.
However wse do hope to implement this in the near future. _________________ Lior
TypeMock Support Group |
|
| Back to top |
|
 |
|