コード例 #1
0
        public void InstanceDataAttribute_succeeds_for_parameterless_method( )
        {
            var method = ParameterlessMethod( );

            var attribute = new InstanceDataAttribute( );
            var data      = attribute.GetData(method);

            var item = Assert.Single(data);

            Assert.Empty(item);
        }
コード例 #2
0
        public void InstanceDataAttribute_succeeds_for_parameterized_method( )
        {
            var method         = ParameterizedMethod(0);
            var parameterTypes = GetParameterTypes(method);

            var attribute = new InstanceDataAttribute( );
            var data      = attribute.GetData(method);

            var item     = Assert.Single(data);
            var argument = Assert.Single(item);

            Assert.Equal(parameterTypes[0], argument.GetType( ));
        }
コード例 #3
0
        public void InstanceDataAttribute_succeeds_for_method_requiring_STA_thread(ApartmentState apartmentState)
        {
            var method         = StaTestMethod(null);
            var parameterTypes = GetParameterTypes(method);

            object[][] data   = null;
            var        thread = new Thread(() => {
                var attribute = new InstanceDataAttribute( );
                data          = attribute.GetData(method).ToArray( );
            })
            {
                IsBackground = true
            };

            thread.SetApartmentState(apartmentState);
            thread.Start( );
            thread.Join( );

            var item     = Assert.Single(data);
            var argument = Assert.Single(item);

            Assert.Equal(parameterTypes[0], argument.GetType( ));
        }