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); }
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); } }
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); } }