示例#1
0
        public void checkforchengeMood()
        {
            //create mood analyser reflection object analyser
            moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
            string result = analyser.ChengeMoodDynamically("happy");

            Assert.AreEqual("happy", result);
        }
示例#2
0
        public void checkFordefaultConstructor()
        {
            //MoodAnalyzer mod = new MoodAnalyzer();
            //create mood analyser reflection object analyser
            moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
            //call the default constructor
            //return the constructor information to the return object
            ConstructorInfo returnObject = analyser.dConstructor();
            //pass the return object as argument to createmoodanaliser and class name as a string argument
            object constructor = analyser.creteMoodAnalyser(returnObject, "MoodAnalyzer");

            //if constructor name and moodanalyzer same then pass the test
            Assert.IsInstanceOf(typeof(MoodAnalyzer), constructor);
        }
示例#3
0
        public void checkForParamterisedConstructor()
        {
            MoodAnalyzer mod = new MoodAnalyzer("i am in sad mood");
            //create mood analyser reflection object analyser
            moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
            //call the parameterised constructor
            //return the constructor information to the return object
            ConstructorInfo returnObject = analyser.ParameteriseConstructor(1);
            //send return object as argument to create mood analuser
            object constructor = analyser.creteMoodAnalyser(returnObject, "MoodAnalyzer", "i am in sad mood");

            //object provided as an actual value is an instance of the expected type at that time we use isinstanceof
            Assert.IsInstanceOf(typeof(MoodAnalyzer), constructor);
        }
示例#4
0
 public void checkForMethodNotFoundForParameterisedConstructor()
 {
     try
     {
         //create mood analyser reflection object analyser
         moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
         //call the default constructor
         //return the constructor information to the return object
         ConstructorInfo returnObject = analyser.ParameteriseConstructor(1);
         //send null ass ConstructorInfo and throws exception catch in catch block
         ConstructorInfo mood        = null;
         object          constructor = analyser.creteMoodAnalyser(mood, "MoodAnalyzer", "i am in sad mood");
     }
     catch (Exception e)
     {
         //exception massage same ass "method not found" then pass the test
         Assert.AreEqual("method not found", e.Message);
     }
 }
示例#5
0
        public void checkForClassNotFoundForParameterisedConstructor()
        {
            try
            {
                //create mood analyser reflection object analyser
                moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
                //call the default constructor
                //return the constructor information to the return object
                ConstructorInfo returnObject = analyser.ParameteriseConstructor(1);
                // send wrong class as argumet then throws exception and catch in catch block
                object constructor = analyser.creteMoodAnalyser(returnObject, "mood", "i am in sad mood");
            }

            catch (Exception e)
            {
                //exception massage same ass class not found then pass the test
                Assert.AreEqual("class not found", e.Message);
            }
        }
示例#6
0
 public void checkForMethodNotFound()
 {
     try
     {
         //create mood analyser reflection object analyser
         moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
         //call the default constructor
         //return the constructor information to the return object
         ConstructorInfo returnObject = analyser.dConstructor();
         //send null as constructor information it throws excption
         ConstructorInfo mood        = null;
         object          constructor = analyser.creteMoodAnalyser(mood, "MoodAnalyzer");
     }
     catch (Exception e)
     {
         //method not found and e.massage same then pass the test
         Assert.AreEqual("method not found", e.Message);
     }
 }
示例#7
0
        public void checkForClassNotFound()
        {
            try
            {
                //create mood analyser reflection object analyser
                moodAnalyserReflector <MoodAnalyzer> analyser = new moodAnalyserReflector <MoodAnalyzer>();
                //call the default constructor
                //return the constructor information to the return object
                ConstructorInfo returnObject = analyser.dConstructor();
                //send the wrong class name as string and throws exception
                object constructor = analyser.creteMoodAnalyser(returnObject, "mood");
            }

            catch (Exception e)
            {
                //if e.massage same as class not found then pass the test
                Assert.AreEqual("class not found", e.Message);
            }
        }