public void Should_throw_correct_exception_when_arguments_for_constructor_are_specified() { // Arrange var reason = @"a reason that spans a couple of lines."; var thrower = new DefaultExceptionThrower(); // Act var exception = Record.Exception( () => thrower.ThrowFailedToGenerateProxyWithArgumentsForConstructor(typeof(string), reason)); // Assert var expectedMessage = @" Failed to create fake of type ""System.String"" with the specified arguments for the constructor: a reason that spans a couple of lines. "; exception.Should() .BeAnExceptionOfType<FakeCreationException>() .WithMessage(expectedMessage); }
public void Should_throw_correct_exception_when_resolved_constructors_are_used(DefaultExceptionThrowerTestCase testCase) { // Arrange var thrower = new DefaultExceptionThrower(); // Act var exception = Record.Exception( () => thrower.ThrowFailedToGenerateProxyWithResolvedConstructors( testCase.TypeOfFake, testCase.ReasonForFailureOfDefaultConstructor, testCase.ResolvedConstructors)); // Assert exception.Should() .BeAnExceptionOfType<FakeCreationException>() .WithMessage(testCase.ExpectedMessage); }
public void Setup() { this.thrower = new DefaultExceptionThrower(); }