Example #1
0
        public void Given_MoodAnalyse_ClassName_Should_Return_MoodAnalyse_Object()
        {
            object expected = new MoodAnalyser();
            object obj      = MoodAnalyseReflector.CreateMoodAnalyse("MoodAnalyserProblem.MoodAnalyser", "MoodAnalyser");

            expected.Equals(obj);
        }
Example #2
0
        public void Given_Happy_Message_With_Reflector_Should_Return_Happy()
        {
            string expected = "HAPPY";
            string result   = MoodAnalyseReflector.SetField("HAPPY", "message");

            Assert.AreEqual(expected, result);
        }
Example #3
0
        public void Given_Happy_Mood_Using_Reflection_When_Proper_Should_Return_Happy()
        {
            string expected = "HAPPY";
            string mood     = MoodAnalyseReflector.InvokeAnalyseMood("Happy", "AnalyseMood");

            Assert.AreEqual(expected, mood);
        }
Example #4
0
        public void Given_Proper_Message_To_MoodAnalyse_Should_Return_MoodAnalyse_Object()
        {
            object expected = new MoodAnalyser("HAPPY");
            object obj      = MoodAnalyseReflector.CreateMoodAnalyseUsingParameterizedConstructor("MoodAnalyserProblem.MoodAnalyser", "MoodAnalyser", "I am in Happy Mood");

            expected.Equals(obj);
        }
Example #5
0
 public void Given_Happy_Message_Improper_Field_Should_Throw_MoodAnalyserCustomException()
 {
     try
     {
         string result = MoodAnalyseReflector.SetField("HAPPY", "any");
     }
     catch (MoodAnalyserCustomException e)
     {
         Assert.AreEqual("Field not found", e.Message);
     }
 }
Example #6
0
 public void Given_Null_Message_With_Reflection_Should_Throw_MoodAnalyserCustomException()
 {
     try
     {
         string message = null;
         string result  = MoodAnalyseReflector.SetField(message, "message");
     }
     catch (MoodAnalyserCustomException e)
     {
         Assert.AreEqual("Message should not be null", e.Message);
     }
 }
Example #7
0
 public void Given_Improper_MoodAnalyse_Constructor_Should_throw_MoodAnalysisException_Indicating_NoSuchMethod()
 {
     try
     {
         object expected = new MoodAnalyser();
         object obj      = MoodAnalyseReflector.CreateMoodAnalyse("MoodAnalyserProblem.MoodAnalyser", "MoodAnalyyserr");
         expected.Equals(obj);
     }
     catch (MoodAnalyserCustomException e)
     {
         Assert.AreEqual("Constructor is Not Found", e.Message);
     }
 }
Example #8
0
 public void Given_Happy_Message_But_Improper_Method_Should_throw_MoodAnalysisException_Indicating_NoSuchMethod()
 {
     try
     {
         string expected = "HAPPY";
         string mood     = MoodAnalyseReflector.InvokeAnalyseMood("Happy", "AnalyyseMood");
         expected.Equals(mood);
     }
     catch (MoodAnalyserCustomException e)
     {
         Assert.AreEqual("Constructor is Not Found", e.Message);
     }
 }
Example #9
0
 public void Given_Proper_Message_But_Improper_MoodAnalyse_ClassName_Should_throw_MoodAnalysisException_Indicating_NoSuchClass()
 {
     try
     {
         object expected = new MoodAnalyser();
         object obj      = MoodAnalyseReflector.CreateMoodAnalyseUsingParameterizedConstructor("MoodAnalyserProblem.MoodAnalyyser", "MoodAnalyyser", "I am in Happy Mood");
         expected.Equals(obj);
     }
     catch (MoodAnalyserCustomException e)
     {
         Assert.AreEqual("Class Not Found", e.Message);
     }
 }