public void GetDataShouldReadDataFromMethodInDifferentClass() { var methodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod2"); this.dynamicDataAttribute = new DynamicDataAttribute("ReusableTestDataMethod2", typeof(DummyTestClass2), DynamicDataSourceType.Method); var data = this.dynamicDataAttribute.GetData(methodInfo); Assert.IsTrue(data is IEnumerable <object[]>); Assert.IsTrue(data.ToList().Count == 2); }
public void GetDataShoudThrowExceptionIfInvalidPropertyNameIsSpecifiedOrPropertyDoesNotExist() { Action action = () => { this.dynamicDataAttribute = new DynamicDataAttribute("ABC"); this.dynamicDataAttribute.GetData(this.testMethodInfo); }; ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException)); }
public void GetDataShouldReadDataFromProperty() { var methodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod1"); this.dynamicDataAttribute = new DynamicDataAttribute("ReusableTestDataProperty"); var data = this.dynamicDataAttribute.GetData(methodInfo); Assert.IsTrue(data is IEnumerable <object[]>); Assert.IsTrue(data.ToList().Count == 2); }
public void GetDataShouldThrowExceptionIfPropertyReturnsNull() { Action action = () => { var methodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod4"); this.dynamicDataAttribute = new DynamicDataAttribute("NullProperty", typeof(DummyTestClass)); this.dynamicDataAttribute.GetData(methodInfo); }; ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException)); }
public void TestInit() { this.dummyTestClass = new DummyTestClass(); this.testMethodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod1"); this.dynamicDataAttribute = new DynamicDataAttribute("ReusableTestDataProperty"); }