public void CacheProxyReplaysException() { var exceptionMessage = "message"; var exception = new CustomException(exceptionMessage); var repo = new FakeRepositoryThrows(exception); var source = Mimic.Record <IFakeRepository>(repo); try { source.ParameterlessFn(); Assert.Fail("Expect CustomException"); } catch (CustomException) { } var log = Mimic.GetHistory(source); var otherRepo = new FakeRepositoryDoubles(); var testee = Mimic.Cache <IFakeRepository>(otherRepo, log); try { testee.ParameterlessFn(); Assert.Fail(); } catch (CustomException e) { } catch (Exception e) { Assert.Fail(); } }
public void BehaviourVerifier_WhenUnexpectedExceptionIsThrown_ShouldIncludeExceptionDetailInTheLog() { var repo = new FakeRepositoryDoubles(); var recorder = Mimic.Record <IFakeRepository>(repo); recorder.Function(1); History history = Mimic.GetHistory(recorder); var testee = Mimic.GetBehaviourVerifier(history); var result = testee.ConfirmBehaviourHasNotChanged(new FakeRepositoryThrows(new CustomException())); Assert.IsTrue(testee.VerificationLog.ToString().Contains("CustomException")); }
public void BehaviourVerifier_VerifiesExceptionThrown_FailsWhenNotExpectedAndDoesOccur_WithNonNullReturnValue() { var repo = new FakeRepositoryDoubles(); var recorder = Mimic.Record <IFakeRepository>(repo); recorder.Function(1); History history = Mimic.GetHistory(recorder); var testee = Mimic.GetBehaviourVerifier(history); var result = testee.ConfirmBehaviourHasNotChanged(new FakeRepositoryThrows(new CustomException())); Assert.False(result); }