public void VerifyUnexposedMethodIgnoresVerifying(MethodAttributes attributes) { var method = Mock.Of<MethodInfo>(x => x.Attributes == attributes && x.ReturnType == typeof(object)); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(method)); }
public void VerifyEventDoesNotThrowWhenMethodDoesNotExposeAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var @event = typeof(ClassForIndirectReference).GetEvent("Event"); Assert.DoesNotThrow(() => sut.Verify(@event)); }
public void VerifyMethodDoesNotThrowWhenMethodDoesNotExposeAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var method = new Methods<ClassForIndirectReference>().Select(x => x.Method(null, null)); Assert.DoesNotThrow(() => sut.Verify(method)); }
public void VerifyMethodThrowsWhenMethodExposesAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly, Assembly.Load("Jwc.Experiment.Idioms") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var method = new Methods<ClassForIndirectReference>().Select(x => x.Method(null, null)); var exception = Assert.Throws<NotExposedReferenceException>(() => sut.Verify(method)); Assert.Contains("Jwc.Experiment.Idioms", exception.Message); }
public void VerifyFieldDoesNotThrowWhenFieldDoesNotExposeAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var field = new Fields<ClassForIndirectReference>().Select(x => x.Field); Assert.DoesNotThrow(() => sut.Verify(field)); }
public void VerifyUnexposedPropertyIgnoresVerifying(MethodAttributes attributes) { var getMethod = Mock.Of<MethodInfo>(x => x.Attributes == attributes && x.ReturnType == typeof(object)); var propertyInfo = Mock.Of<PropertyInfo>(x => x.GetGetMethod(true) == getMethod); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(propertyInfo)); }
public void VerifyUnexposedConstructorIgnoresVerifying(MethodAttributes attributes) { var parameterInfos = new[] { Mock.Of<ParameterInfo>(p => p.ParameterType == typeof(object)) }; var constructor = Mock.Of<ConstructorInfo>( x => x.Attributes == attributes && x.GetParameters() == parameterInfos); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(constructor)); }
public void VerifyNullAssemblyThrows() { var sut = new NotExposedReferenceAssertion(); Assert.Throws<ArgumentNullException>(() => sut.Verify((Assembly)null)); }
public void VerifyConstructorThrowsWhenConstructorExposesAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly, Assembly.Load("Jwc.Experiment.Idioms") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var constructor = Constructors.Select(() => new ClassForIndirectReference(null, null)); var exception = Assert.Throws<NotExposedReferenceException>(() => sut.Verify(constructor)); Assert.Contains("Jwc.Experiment.Idioms", exception.Message); }
public void VerifyConstructorDoesNotAddressMethodBody() { var indirectReferences = new[] { Assembly.Load("Ploeh.AutoFixture") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var constructor = Constructors.Select(() => new ClassForIndirectReference()); Assert.DoesNotThrow(() => sut.Verify(constructor)); }
public void VerifyConstructorDoesNotThrowWhenConstructorDoesNotExposeAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var constructor = Constructors.Select(() => new ClassForIndirectReference(null, null)); Assert.DoesNotThrow(() => sut.Verify(constructor)); }
public void VerifyUnexposedFieldIgnoresVerifying(FieldAttributes attributes) { var field = Mock.Of<FieldInfo>(x => x.Attributes == attributes && x.FieldType == typeof(object)); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(field)); }
public void VerifyFieldIndependentlyVerifies() { var indirectReferences = new[] { Assembly.Load("Ploeh.AutoFixture") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var constructor = Constructors.Select(() => new ClassForIndirectReference(null, null)); var field = new Fields<ClassForIndirectReference>().Select(x => x.Field); Assert.Throws<NotExposedReferenceException>(() => sut.Verify(field)); Assert.DoesNotThrow(() => sut.Verify(constructor)); }
public void VerifyEventThrowsWhenEventExposesAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly, Assembly.Load("Jwc.Experiment.Idioms") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var @event = typeof(ClassForIndirectReference).GetEvent("Event"); var exception = Assert.Throws<NotExposedReferenceException>(() => sut.Verify(@event)); Assert.Contains("Jwc.Experiment.Idioms", exception.Message); }
public void VerifyPropertyDoesNotThrowWhenPropertyDoesNotExposeAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var property = new Properties<ClassForIndirectReference>().Select(x => x.Property); Assert.DoesNotThrow(() => sut.Verify(property)); }
public void VerifyUnexposedEventIgnoresVerifying(MethodAttributes attributes) { var addMethod = Mock.Of<MethodInfo>(x => x.Attributes == attributes && x.ReturnType == typeof(object)); var @event = Mock.Of<EventInfo>( x => x.GetAddMethod(true) == addMethod && x.GetRemoveMethod(true) == addMethod); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(@event)); }
public void VerifyPropertyThrowsWhenPropertyExposesAnyIndirectReference() { var indirectReferences = new[] { GetType().Assembly, Assembly.Load("Ploeh.AutoFixture"), typeof(object).Assembly }; var sut = new NotExposedReferenceAssertion(indirectReferences); var property = new Properties<ClassForIndirectReference>().Select(x => x.Property); var exception = Assert.Throws<NotExposedReferenceException>(() => sut.Verify(property)); Assert.Contains("Ploeh.AutoFixture", exception.Message); }
public void VerifyTypeThrowsWhenBaseTypeExposesAnyIndirectReference() { var indirectReferences = new[] { Assembly.Load("Jwc.Experiment.Idioms") }; var sut = new NotExposedReferenceAssertion(indirectReferences); var type = typeof(TypeForIndirectReference); var exception = Assert.Throws<NotExposedReferenceException>(() => sut.Verify(type)); Assert.Contains("Jwc.Experiment.Idioms", exception.Message); }
public void VerifyUnexposedTypeIgnoresVerifying() { var type = typeof(object).Assembly.GetTypes().First(t => t.IsNotPublic); var sut = new NotExposedReferenceAssertion(new[] { typeof(object).Assembly }); Assert.DoesNotThrow(() => sut.Verify(type)); }