public void ClassStartDoesNotThrowUponMatchingConstructor( Type classType, object[] exemplarArguments, ParadigmTestClassCommand sut, IAttributeInfo attributeInfo, ParadigmDataAttribute attribute) { Mock.Get(sut.TypeUnderTest).SetupGet(x => x.Type) .Returns(classType); Mock.Get(sut.TypeUnderTest).Setup(x => x.GetCustomAttributes(typeof(ParadigmDataAttribute))) .Returns(new[] { attributeInfo }); Mock.Get(attributeInfo).Setup(x => x.GetInstance<ParadigmDataAttribute>()) .Returns(attribute); Mock.Get(attribute).Setup(x => x.GetData(It.IsAny<ConstructorInfo>(), It.IsAny<Type[]>())) .Returns(new[] { exemplarArguments }); Assert.Null(sut.ClassStart()); }
public void ClassStartThrowsUponMismatchingConstructors( Type classType, object[] exemplarArguments, string expectedMessage, ParadigmTestClassCommand sut, IAttributeInfo attributeInfo, ParadigmDataAttribute attribute) { Mock.Get(sut.TypeUnderTest).SetupGet(x => x.Type) .Returns(classType); Mock.Get(sut.TypeUnderTest).Setup(x => x.GetCustomAttributes(typeof (ParadigmDataAttribute))) .Returns(new[] { attributeInfo }); Mock.Get(attributeInfo).Setup(x => x.GetInstance<ParadigmDataAttribute>()) .Returns(attribute); Mock.Get(attribute).Setup(x => x.GetData(It.IsAny<ConstructorInfo>(), It.IsAny<Type[]>())) .Returns(new [] { exemplarArguments }); var exception = sut.ClassStart(); Assert.IsType<InvalidParadigmExemplarException>(exception); Assert.Equal(expectedMessage, exception.Message); }
private IEnumerable<IParadigmExemplar> GetExemplars(ITypeInfo typeUnderTest, ConstructorInfo constructor, ParadigmDataAttribute attribute) { var attrData = attribute.GetData(constructor, constructor.GetParameters().Select(x => x.ParameterType).ToArray()); return attrData.Select(dataItems => new ParadigmExemplar(typeUnderTest, constructor.GetParameters(), dataItems)); }