public static IReflectionAttributeInfo ExpectThatAttribute(string displayName = null, string skip = null, int timeout = 0) { var attribute = new ExpectThatAttribute(); if (displayName != null) { attribute.DisplayName = displayName; } if (skip != null) { attribute.Skip = skip; } if (timeout != 0) { attribute.Timeout = timeout; } var mock = new Mock <IReflectionAttributeInfo>(MockBehavior.Strict); mock.SetupGet(x => x.Attribute).Returns(attribute); mock.Setup(x => x.GetNamedArgument <string>("DisplayName")).Returns(attribute.DisplayName); mock.Setup(x => x.GetNamedArgument <string>("Skip")).Returns(attribute.Skip); mock.Setup(x => x.GetNamedArgument <int>("Timeout")).Returns(attribute.Timeout); return(mock.Object); }
public ExpectatThatTestMethodInfo(MethodInfo methodInfo, ExpectThatAttribute expectAttribute) { _reflectionMethodInfo = Reflector.Wrap(methodInfo); var expectAttributeMock = new Mock <IReflectionAttributeInfo>(); expectAttributeMock.SetupGet(x => x.Attribute).Returns(expectAttribute); expectAttributeMock.Setup(x => x.GetNamedArgument <string>("DisplayName")) .Returns(expectAttribute.DisplayName); expectAttributeMock.Setup(x => x.GetNamedArgument <string>("Skip")).Returns(expectAttribute.Skip); expectAttributeMock.Setup(x => x.GetNamedArgument <int>("Timeout")).Returns(expectAttribute.Timeout); _expectAttribute = expectAttributeMock.Object; }
public static ITestMethod TestMethod(Type type, string methodName, string displayName = null, string skip = null, int timeout = 0) { var @class = TestClass(type); var methodInfo = type.GetMethod(methodName); if (methodInfo == null) { throw new Exception($"Unknown method: {type.FullName}.{methodName}"); } var expectAttribute = new ExpectThatAttribute() { DisplayName = displayName, Skip = skip, Timeout = timeout }; var testMethodInfo = new ExpectatThatTestMethodInfo(methodInfo, expectAttribute); return(new TestMethod(@class, testMethodInfo)); }