Hi.
I'm trying to make a mocked instance throw an exception when a specific method is called.
[TestMethod]
[ExpectedException(typeof(RepositoryExpectedException))]
public void CreateTest3()
{
using (RecordExpectations recorder = new RecordExpectations())
{
RepositoryNHibernate repNHibernate = new RepositoryNHibernate(typeof(Customer).Name);
recorder.MockStaticConstructors();
repNHibernate.Create(null);
recorder.Throw(new RepositoryExpectedException());
}
// Test
Repository target = new Repository(typeof(Customer).Name);
target.Create(BuildTestCustomer());
}
I thought (from documentation) that the recorder.Throw() statement would make Create throw the RepositoryExpectedException.
The thing is that is not. What am I doing wrong?
Thanks in advance.
Hugo