public void GivenMoodAnalyser_WhenProper_ShouldReturnObject() { try { MoodAnalyserFactory moodAnalyserFactory = new MoodAnalyserFactory(); ConstructorInfo constructor = moodAnalyserFactory.GetConstructor(1); object createdObject = moodAnalyserFactory.CreateObjectUsingParameterizedConstructor(constructor.DeclaringType.FullName, constructor, "I am in Happy mood"); Assert.IsInstanceOf(typeof(MoodAnalysermain), createdObject); } catch (MoodAnalyserException) { } }
public void GivenConstructor_WhenImproper_ShouldthrowException() { try { string className = "MoodAnalyser"; MoodAnalyserFactory moodAnalyserFactory = new MoodAnalyserFactory(); ConstructorInfo constructor = moodAnalyserFactory.GetConstructor(2); object createdObject = moodAnalyserFactory.CreateObjectUsingConstructor(className, constructor, 1); } catch (MoodAnalyserException e) { Assert.AreEqual(MoodAnalyserException.ExceptionType.ClassNotFound, e.TYPE); } }