I'm having a hard time getting expectations to work for TimeZoneInfo,
and was hoping someone could take a look and verify I'm doing this
correctly? Here's some sample code:
public interface IServiceThatUsesTimeZoneInfo
{
string MethodWithTimeZoneInfoParameter(TimeZoneInfo tzInfo);
}
public class CodeUnderTest
{
IServiceThatUsesTimeZoneInfo _service;
public CodeUnderTest(IServiceThatUsesTimeZoneInfo service)
{
_service = service;
}
public string MethodToTest()
{
return
_service.MethodWithTimeZoneInfoParameter(TimeZoneInfo.FindSystemTimeZoneById("Pacific
Standard Time"));
}
}
[TestFixture]
public class TimeZoneInfoTest
{
[Test]
public void TestTimeZoneInfoMock()
{
RhinoMocks.Logger = new
TextWriterExpectationLogger(Console.Out);
IServiceThatUsesTimeZoneInfo fakeService =
MockRepository.GenerateMock<IServiceThatUsesTimeZoneInfo>();
fakeService.Expect(service =>
service.MethodWithTimeZoneInfoParameter(TimeZoneInfo.FindSystemTimeZoneById("Pacific
Standard Time"))).Return("hello world");
//fakeService.Expect(service =>
service.MethodWithTimeZoneInfoParameter(TimeZoneInfo.FindSystemTimeZoneById("Pacific
Standard Time"))).IgnoreArguments().Return("hello world");
CodeUnderTest c = new CodeUnderTest(fakeService);
string s = c.MethodToTest();
Assert.AreEqual("hello world", s);
fakeService.VerifyAllExpectations();
}
}
This test fails, unless I add the IgnoreArguments. But you'll see
with the Expectation Logger that they appear to be equal instances of
TimeZoneInfo. Perhaps this is a problem with TimeZoneInfo, and doing
equality checks with them? How can I get to TimeZoneInfo instances to
match up with Rhino Mocks expectations?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.