Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void GetDataShoudThrowExceptionIfInvalidPropertyNameIsSpecifiedOrPropertyDoesNotExist()
        {
            Action action = () =>
            {
                this.dynamicDataAttribute = new DynamicDataAttribute("ABC");
                this.dynamicDataAttribute.GetData(this.testMethodInfo);
            };

            ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 public void TestInit()
 {
     this.dummyTestClass       = new DummyTestClass();
     this.testMethodInfo       = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod1");
     this.dynamicDataAttribute = new DynamicDataAttribute("ReusableTestDataProperty");
 }