Exemplo n.º 1
0
 public void Given_Null_Message_Should_Throw_MoodAnalysisException_Indicating_Null_Message()
 {
     try
     {
         //Arrange
         string message   = null;
         string fieldName = "message";
         //Act
         string actual = MoodAnalyserFactory.SetField(message, fieldName);
     }
     catch (MoodAnalysisException e)
     {
         //Assert
         Assert.AreEqual("message should not be null", e.Message);
     }
 }
Exemplo n.º 2
0
 public void Given_Improper_Constructor_Name_Should_Throw_MoodAnalysisException_Indicating_No_Such_Constructor()
 {
     try
     {
         //Arrange
         string className       = "MoodAnalyzerProblem.MoodAnalyser";
         string constructorName = "WrongConstructorName";
         //Act
         object resultObj = MoodAnalyserFactory.CreateMoodAnalyserObject(className, constructorName);
     }
     catch (MoodAnalysisException e)
     {
         //Assert
         Assert.AreEqual("constructor not found", e.Message);
     }
 }
Exemplo n.º 3
0
 public void Given_Improper_Field_Name_Should_Throw_MoodAnalysisException_Indicating_No_Such_Field()
 {
     try
     {
         //Arrange
         string message   = "HAPPY";
         string fieldName = "wrongName";
         //Act
         string actual = MoodAnalyserFactory.SetField(message, fieldName);
     }
     catch (MoodAnalysisException e)
     {
         //Assert
         Assert.AreEqual("no such field found", e.Message);
     }
 }
Exemplo n.º 4
0
 public void Given_Improper_Method_Name_Should_Throw_MoodAnalysisException_Indicating_No_Such_Method()
 {
     try
     {
         //Arrange
         string message    = "HAPPY";
         string methodName = "WrongMethodName";
         //Act
         string actual = MoodAnalyserFactory.InvokeAnalyseMood(message, methodName);
     }
     catch (MoodAnalysisException e)
     {
         //Assert
         Assert.AreEqual("no such method", e.Message);
     }
 }
Exemplo n.º 5
0
 public void Given_Improper_Constructor_Name_Should_Throw_MoodAnalysisException_For_Parameterized_Constructor()
 {
     try
     {
         //Arrange
         string            className       = "MoodAnalyser.MoodAnalyserClass";
         string            constructorName = "WrongConstructorName";
         MoodAnalyserClass expectedObj     = new MoodAnalyserClass("HAPPY");
         //Act
         object resultObj = MoodAnalyserFactory.CreateMoodAnalyserObjectUsingParametrisedConstructor(className, constructorName, "HAPPY");
     }
     catch (MoodAnalysisException e)
     {
         //Assert
         Assert.AreEqual("constructor not found", e.Message);
     }
 }
Exemplo n.º 6
0
        public void Change_Mood_Dynamically()
        {
            string result = MoodAnalyserFactory.SetField("Happy", "message");

            Assert.AreEqual("Happy", result);
        }
Exemplo n.º 7
0
        public void Given_HAPPYMessag_WithReflector_should_ReturnHAPPY()
        {
            string result = MoodAnalyserFactory.SetField("HAPPY", "message");

            Assert.AreEqual("HAPPY", result);
        }