Beispiel #1
0
        public void Should_fail_for_non_interceptable_methods(NonInterceptableTestCase testCase)
        {
            // Arrange
            string reason = null;

            // Act
            var result = this.validator.MethodCanBeInterceptedOnInstance(testCase.Method, testCase.Target, out reason);

            // Assert
            Assert.That(result, Is.False);
            Assert.That(reason, Is.EqualTo(testCase.FailReason));
        }
        public void Should_fail_for_non_interceptable_methods(NonInterceptableTestCase testCase)
        {
            Guard.AgainstNull(testCase, nameof(testCase));

            // Arrange

            // Act
            var result = this.validator.MethodCanBeInterceptedOnInstance(testCase.Method, testCase.Target, out var reason);

            // Assert
            result.Should().BeFalse();
            reason.Should().Be(testCase.FailReason);
        }
Beispiel #3
0
 public static IEnumerable <object[]> NonInterceptableMembers()
 {
     return(TestCases.FromObject(
                NonInterceptableTestCase.Create(
                    () => new object().GetType(),
                    "Non virtual methods can not be intercepted."),
                NonInterceptableTestCase.Create(
                    () => object.Equals("foo", "bar"),
                    "Static methods can not be intercepted."),
                NonInterceptableTestCase.Create(
                    () => "foo".Count(),
                    "Extension methods can not be intercepted since they're static."),
                NonInterceptableTestCase.Create(
                    () => new TypeWithSealedOverride().ToString(),
                    "Sealed methods can not be intercepted.")));
 }