예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void Setup()
 {
     this.thrower = new DefaultExceptionThrower();
 }