public object Get() { if (!_throw) { return(StrictSubstitute.GetDefault(_returnType)); } else { throw new AccessViolationException("lolokimono"); } }
public void ShouldAllowOverridingExceptionsWithNSubstituteSyntax() { //GIVEN var sub = new StrictSubstitute().For <ITested>(s => { s.MethodWithReturn(1, 2, "a").Returns("123"); s.When(_ => _.VoidMethod(1, 2, "2")).Do(c => { }); }); var x = sub.MethodWithReturn(1, 2, "a"); Assert.AreEqual("123", x); Assert.Throws <AccessViolationException>(() => x = sub.MethodWithReturn(1, 4, "a")); sub.VoidMethod(1, 2, "2"); Assert.Throws <AccessViolationException>(() => sub.VoidMethod(1, 2, "3")); }