public void BuilderIsCorrect() { var builder = new Fixture(); var sut = new ObjectDisposalAssertion(builder); var actual = sut.Builder; Assert.Same(builder, actual); }
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)); }
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)); }
public void VerifyClassThrowsWhenClassIsNotDisposable() { var sut = new ObjectDisposalAssertion(new Fixture()); Assert.Throws<ArgumentException>(() => sut.Verify(typeof(ClassWithDispose))); }
public void VerifyClassDoesNotAssertDisposeMethod() { var sut = new ObjectDisposalAssertion(new Fixture()); Assert.ThrowsDelegate action = () => sut.Verify(typeof(ClassForOnlyDisposable)); Assert.DoesNotThrow(action); }
public void VerifyClassAssertsOtherDisposeMethod() { var sut = new ObjectDisposalAssertion(new Fixture()); Assert.ThrowsDelegate action = () => sut.Verify(typeof(ClassWithOtherDispose)); Assert.Throws<ObjectDisposalException>(action); }
public void SutIsIdiomaticMemberAssertion() { var sut = new ObjectDisposalAssertion(new Fixture()); Assert.IsAssignableFrom<IdiomaticAssertion>(sut); }
public void VerifyNullPropertyThrows() { var sut = new ObjectDisposalAssertion(new Fixture()); Assert.Throws<ArgumentNullException>(() => sut.Verify((PropertyInfo)null)); }
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); }
public void VerifyMethodThrowsWhenTargetIsNotDisposable() { var sut = new ObjectDisposalAssertion(new Fixture()); var method = new Methods<ClassForNonDisposable>().Select(x => x.Method()); Assert.Throws<ArgumentException>(() => sut.Verify(method)); }
public void VerifyMethodThrowsWhenMethodThrowsOtherException() { var sut = new ObjectDisposalAssertion(new Fixture()); var method = new Methods<ClassForDisposable>().Select(x => x.ThrowNotSupportedException()); Assert.Throws<TargetInvocationException>(() => sut.Verify(method)); }
public void VerifyMethodThrowsWhenMethodDoesNotThrowObjectDisposedException() { var sut = new ObjectDisposalAssertion(new Fixture()); var method = new Methods<ClassForDisposable>().Select(x => x.DoNotThrowException()); Assert.Throws<ObjectDisposalException>(() => sut.Verify(method)); }