Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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);
            }
        }