Ejemplo n.º 1
0
 private void AssertThatProxyWasGeneratedWhenArgumentsForConstructorAreSpecified(Type typeOfFake, ProxyGeneratorResult result, IProxyOptions proxyOptions)
 {
     if (!result.ProxyWasSuccessfullyGenerated && proxyOptions.ArgumentsForConstructor != null)
     {
         this.thrower.ThrowFailedToGenerateProxyWithArgumentsForConstructor(typeOfFake, result.ReasonForFailure);
     }
 }
        public void Should_set_reason_for_failure_when_constructor_with_reason_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(reasonForFailure: "reason");

            // Assert
            result.ReasonForFailure.Should().Be("reason");
        }
        public void Should_set_reason_for_failure_when_constructor_with_reason_and_exception_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(reasonForFailure: "reason", exception: new Exception("exception message"));

            // Assert
            result.ReasonForFailure.Should().Be("reason\r\nAn exception was caught during this call. Its message was:\r\nexception message");
        }
        public void Should_set_that_proxy_was_successfully_created_when_constructor_with_proxy_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(A.Fake<ITaggable>());

            // Assert
            result.ProxyWasSuccessfullyGenerated.Should().BeTrue();
        }
        public void Should_set_that_proxy_was_not_successfully_created_when_constructor_with_error_message_is_used()
        {
            // Arrange
            
            // Act
            var result = new ProxyGeneratorResult(reasonForFailure: "reason");

            // Assert
            result.ProxyWasSuccessfullyGenerated.Should().BeFalse();
        }
        public void Should_set_reason_for_failure_when_using_constructor_with_reason()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(reasonForFailure: "reason");

            // Assert
            Assert.That(result.ReasonForFailure, Is.EqualTo("reason"));
        }
        public void Should_set_proxy_when_constructor_with_proxy_is_used()
        {
            // Arrange
            var proxy = A.Fake<ITaggable>();

            // Act
            var result = new ProxyGeneratorResult(proxy, A.Dummy<ICallInterceptedEventRaiser>());

            // Assert
            result.GeneratedProxy.Should().Be(proxy);
        }
        public void Should_set_event_raiser()
        {
            // Arrange
            var eventRaiser = A.Fake<ICallInterceptedEventRaiser>();

            // Act
            var result = new ProxyGeneratorResult(A.Dummy<ITaggable>(), eventRaiser);

            // Assert
            result.CallInterceptedEventRaiser.Should().Be(eventRaiser);
        }
        public void Should_set_reason_for_failure_when_constructor_with_reason_and_exception_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(
                reasonForFailure: "reason",
                exception: new InvalidOperationException("exception message"));

            // Assert
            var expectedReason = new[]
            {
                "reason",
                "An exception of type System.InvalidOperationException was caught during this call. Its message was:",
                "exception message"
            }.AsTextBlock();

            result.ReasonForFailure.Should().StartWith(expectedReason);
        }
Ejemplo n.º 10
0
        public void Should_set_reason_for_failure_from_exception_when_constructor_with_reason_and_TargetInvocationException_that_has_no_inner_exception_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(
                reasonForFailure: "reason",
                exception: new TargetInvocationException("target invocation exception message", null));

            // Assert
            var expectedReason = new[]
            {
                "reason",
                "An exception of type System.Reflection.TargetInvocationException was caught during this call. Its message was:",
                "target invocation exception message"
            }.AsTextBlock();

            result.ReasonForFailure.Should().StartWith(expectedReason);
        }
Ejemplo n.º 11
0
 private void AssertThatProxyWasGeneratedWhenArgumentsForConstructorAreSpecified(Type typeOfFake, ProxyGeneratorResult result, FakeOptions fakeOptions)
 {
     if (!result.ProxyWasSuccessfullyGenerated && fakeOptions.ArgumentsForConstructor != null)
     {
         this.thrower.ThrowFailedToGenerateProxyWithArgumentsForConstructor(typeOfFake, result.ReasonForFailure);
     }
 }
        public void Should_set_that_proxy_was_successfully_created_when_constructor_with_proxy_and_raiser_is_used()
        {
            // Arrange

            // Act
            var result = new ProxyGeneratorResult(A.Fake<ITaggable>(), A.Fake<ICallInterceptedEventRaiser>());

            // Assert
            Assert.That(result.ProxyWasSuccessfullyGenerated, Is.True);
        }