1

I'm using FakeItEasy to mock stuff within unit tests but somehow i fail to setup pretty basic scenario. ie. i want to throw exception when specific user accesses a method. Help would be nice... thanks

A.CallTo(() => m_fancyRepository
                .CanIDoFancyThings(A<User>
                    .That
                    .Matches(u => u.Id.Equals(m_user.Id)))
                .Verify())
                .Throws(new Exception("omg !!! ???!"));
eugeneK
  • 10,750
  • 19
  • 66
  • 101

1 Answers1

2

Try to remove the Verify() method after the stub, like this:

A.CallTo(() => m_fancyRepository.CanIDoFancyThings(
            A<User>.That.Matches(u => u.Id.Equals(m_user.Id))))
            .Throws(new Exception("omg !!! ???!"));
Joel R Michaliszen
  • 4,164
  • 1
  • 21
  • 28