コード例 #1
0
        public void CreateRelayedRequestThrowsNotSupportedExceptionWhenAttributeIsAppliedToUnexpectedCodeElement()
        {
            // Arrange
            var sut       = new SubstituteAttributeRelay();
            var request   = Substitute.For <ICustomAttributeProvider>();
            var attribute = new SubstituteAttribute();

            request.GetCustomAttributes(Arg.Any <Type>(), Arg.Any <bool>()).Returns(new object[] { attribute });
            var context = Substitute.For <ISpecimenContext>();
            // Act
            var e = Assert.Throws <NotSupportedException>(() => sut.Create(request, context));

            // Assert
            Assert.Contains(attribute.ToString(), e.Message);
            Assert.Contains(request.ToString(), e.Message);
        }
コード例 #2
0
        public void CreateRelayedRequestThrowsNotSupportedExceptionWhenAttributeIsAppliedToUnexpectedCodeElement()
        {
            // Fixture setup
            var sut       = new SubstituteAttributeRelay();
            var request   = Substitute.For <EventInfo>();
            var attribute = new SubstituteAttribute();

            request.GetCustomAttributes(Arg.Any <Type>(), Arg.Any <bool>()).Returns(new[] { attribute });
            var context = Substitute.For <ISpecimenContext>();
            // Exercise system
            var e = Assert.Throws <NotSupportedException>(() => sut.Create(request, context));

            // Verify outcome
            Assert.Contains(attribute.ToString(), e.Message);
            Assert.Contains(request.ToString(), e.Message);
            // Teardown
        }
コード例 #3
0
 public void CreateRelayedRequestThrowsNotSupportedExceptionWhenAttributeIsAppliedToUnexpectedCodeElement()
 {
     // Fixture setup
     var sut = new SubstituteAttributeRelay();
     var request = Substitute.For<EventInfo>();
     var attribute = new SubstituteAttribute();
     request.GetCustomAttributes(Arg.Any<Type>(), Arg.Any<bool>()).Returns(new[] { attribute });
     var context = Substitute.For<ISpecimenContext>();
     // Exercise system
     var e = Assert.Throws<NotSupportedException>(() => sut.Create(request, context));
     // Verify outcome
     Assert.Contains(attribute.ToString(), e.Message);
     Assert.Contains(request.ToString(), e.Message);
     // Teardown
 }