示例#1
0
        public void GivenClassName_CreateDefaultObjectUsingReflection(string className, string constructorName)
        {
            //Arrange
            //Act
            object expected = new MoodAnalyzer();
            object actual   = MoodAnalyzerReflection.CreateMoodAnalyzerObject(className, constructorName);

            //Assert
            Assert.AreEqual(expected.GetType(), actual.GetType()); // To check if both objects are of same type
        }
示例#2
0
 public void GivenClassNameImproper_DefaultConstructorThrowNoSuchClassException(string className, string constructorName)
 {
     try
     {
         //Arrange
         object actual = MoodAnalyzerReflection.CreateMoodAnalyzerObject(className, constructorName);
     }
     catch (MoodAnalyzerException ex)
     {
         //Act
         string actual   = ex.Message;
         string expected = "No such class exist!";
         //Assert
         Assert.AreEqual(expected, actual);
     }
 }
示例#3
0
 public void GivenClassName_CreateParamterizedObjectUsingReflection(string className, string constructorName, string message, string expected)
 {
     try
     {
         //Arrange
         moodAnalyzer = (MoodAnalyzer)MoodAnalyzerReflection.CreateMoodAnalyzerObject(className, constructorName, message);
         //Act
         string actual = moodAnalyzer.AnalyseMood();
         //Assert
         Assert.AreEqual(expected, actual);
     }
     catch (MoodAnalyzerException ex)
     {
         //Act
         string actual = ex.Message;
         //Assert
         Assert.AreEqual(expected, actual);
     }
 }