Verify() public method

Verifies that a method throws ObjectDisposedException after its owner(object) is disposed.
public Verify ( MethodInfo method ) : void
method System.Reflection.MethodInfo /// The method. ///
return void
コード例 #1
0
        public void VerifyInterfaceSetPropertyDoesNotThrow()
        {
            // Fixture setup
            var sut = new ObjectDisposalAssertion(new Fixture());
            var property = typeof(IInterfaceWithMembers).GetProperty("SetProperty");
            Assert.NotNull(property);

            // Exercise system and Verify outcome
            Assert.DoesNotThrow(() => sut.Verify(property));
        }
コード例 #2
0
 public void VerifyClassThrowsWhenClassIsNotDisposable()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     Assert.Throws<ArgumentException>(() => sut.Verify(typeof(ClassWithDispose)));
 }
コード例 #3
0
        public void VerifyInterfaceMethodDoesNotThrow()
        {
            // Fixture setup
            var sut = new ObjectDisposalAssertion(new Fixture());
            var method = typeof(IInterfaceWithMembers).GetMethod("Method");
            Assert.NotNull(method);

            // Exercise system and Verify outcome
            Assert.DoesNotThrow(() => sut.Verify(method));
        }
コード例 #4
0
 public void VerifyClassAssertsOtherDisposeMethod()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     Assert.ThrowsDelegate action = () => sut.Verify(typeof(ClassWithOtherDispose));
     Assert.Throws<ObjectDisposalException>(action);
 }
コード例 #5
0
 public void VerifyClassDoesNotAssertDisposeMethod()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     Assert.ThrowsDelegate action = () => sut.Verify(typeof(ClassForOnlyDisposable));
     Assert.DoesNotThrow(action);
 }
コード例 #6
0
 public void VerifyNullPropertyThrows()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     Assert.Throws<ArgumentNullException>(() => sut.Verify((PropertyInfo)null));
 }
コード例 #7
0
        public void VerifyMethodUsesParameterInfoToCreateArguments()
        {
            var parameters = new List<ParameterInfo>();
            var fixture = new Fixture();
            var tracingBuilder = new TracingBuilder(fixture);
            tracingBuilder.SpecimenCreated += (sender, args) =>
            {
                var parameter = args.Request as ParameterInfo;
                    if (parameter != null)
                        parameters.Add(parameter);
            };

            var sut = new ObjectDisposalAssertion(tracingBuilder);
            var method = new Methods<ClassForDisposable>().Select(
                x => x.ThrowObjectDisposedException(null));

            sut.Verify(method);

            Assert.Equal(1, parameters.Count);
        }
コード例 #8
0
 public void VerifyMethodThrowsWhenTargetIsNotDisposable()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     var method = new Methods<ClassForNonDisposable>().Select(x => x.Method());
     Assert.Throws<ArgumentException>(() => sut.Verify(method));
 }
コード例 #9
0
 public void VerifyMethodThrowsWhenMethodThrowsOtherException()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     var method = new Methods<ClassForDisposable>().Select(x => x.ThrowNotSupportedException());
     Assert.Throws<TargetInvocationException>(() => sut.Verify(method));
 }
コード例 #10
0
 public void VerifyMethodThrowsWhenMethodDoesNotThrowObjectDisposedException()
 {
     var sut = new ObjectDisposalAssertion(new Fixture());
     var method = new Methods<ClassForDisposable>().Select(x => x.DoNotThrowException());
     Assert.Throws<ObjectDisposalException>(() => sut.Verify(method));
 }