Example #1
0
        public void Should_Throw_Exception_With_Type_Mismatch()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();

            var tdef = new TestTypeDefinition(new TestObject())
            {
                Parameters = parameters
            };

            IObjectCreator <string> creator = new ObjectCreator <string>();

            Action action = () => creator.Create(tdef);

            action.ShouldThrow <InvalidCastException>();
        }
Example #2
0
        public void Should_return_valid_type()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();
            var testObject = new TestObject();
            var tdef       = new TestTypeDefinition(testObject)
            {
                Parameters = parameters
            };

            IObjectCreator <TestObject> creator = new ObjectCreator <TestObject>();

            var result = creator.Create(tdef);

            result.ShouldBeType(testObject.GetType());
        }
        public void Should_Throw_Exception_With_Type_Mismatch()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();
            
            var tdef = new TestTypeDefinition(new TestObject())
            {               
                Parameters = parameters
            };

            IObjectCreator<string> creator = new ObjectCreator<string>();

            Action action = () => creator.Create(tdef);

            action.ShouldThrow<InvalidCastException>();     
        }
        public void Should_return_valid_type()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();
            var testObject = new TestObject();
            var tdef = new TestTypeDefinition(testObject)
            {            
               Parameters = parameters                
            }; 
           
            IObjectCreator<TestObject> creator = new ObjectCreator<TestObject>();

            var result = creator.Create(tdef);

            result.ShouldBeType(testObject.GetType());          
        }
Example #5
0
        public void Should_return_populated_parameters()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();

            parameters.Add("MyProperty", "5");
            var tdef = new TestTypeDefinition(new TestObject())
            {
                Parameters = parameters
            };

            IObjectCreator <TestObject> creator = new ObjectCreator <TestObject>();

            var result = creator.Create(tdef);

            result.MyProperty.ShouldEqual("5");
        }
        public void Should_return_populated_parameters()
        {
            var parameters = new System.Collections.Specialized.NameValueCollection();
            parameters.Add("MyProperty","5");
            var tdef = new TestTypeDefinition(new TestObject())
            {                
               Parameters = parameters                
            }; 
           
            IObjectCreator<TestObject> creator = new ObjectCreator<TestObject>();

            var result = creator.Create(tdef);

            result.MyProperty.ShouldEqual("5");
           

        }