How to unit test resolve files in NUnit?

I am trying to perform unit test read operations. In this case, I also need to make sure that if a specific user does not have read access, he should get an exception ...

But for some reason, I can’t make it work, can anyone suggest something?

PS: I use Rhino mock and NUnit

+3
source share
3 answers

You can use the "Do" extension for Rhino.Mocks to create a specific exception:

public delegate void ThrowExceptionDelegate();
mystub.Stub(x => x.ReadFile()).Do(new ThrowExceptionDelegate(delegate()
    { throw new IOException(); }
    ));

This will allow you to test the exception handling code.

+2
source

, , . , , , .

, , , , .

+1
+1

Source: https://habr.com/ru/post/1724605/


All Articles