Beispiel #1
0
        public void TestInvokeMoodAnalysis_ShouldReturnMoodAsPerMessage()
        {
            //Arrange
            string methodName   = "AnalyseMood";
            string message      = "he is sad";
            string expectedMood = "SAD";

            //Add
            string actualMood = MoodAnalysisReflecter.InvokeMoodAnalysis(methodName, message);

            //Assert
            Assert.AreEqual(expectedMood, actualMood);
        }
Beispiel #2
0
        public void TestSetFieldValue_ShouldReturnCorrectMood()
        {
            //Arrange
            string fieldName    = "_message";
            string message      = "he is sad";
            string expectedMood = "SAD";

            //Add
            string actualMood = MoodAnalysisReflecter.SetFieldValue(fieldName, message);

            //Assert
            Assert.AreEqual(expectedMood, actualMood);
        }
Beispiel #3
0
        public void MoodAnalysisBuilder_ShouldReturnMoodAnalysisObject()
        {
            //Arrange
            string className        = "MoodAnalyser";
            string constructorName  = className;
            object expectedInstance = new MoodAnalyser();

            //Add
            object actualInstance = MoodAnalysisReflecter.BuildMoodAnalysis(className, constructorName);

            //Assert
            expectedInstance.Equals(actualInstance);
        }
Beispiel #4
0
        public void TestParameterizedMoodAnalysisBuilder_ShouldReturnMoodAnalysisObject()
        {
            //Arrange
            string className        = "MoodAnalyser";
            string constructorName  = className;
            string message          = "he is sad";
            object expectedInstance = new MoodAnalyser(message);

            //Add
            object actualInstance = MoodAnalysisReflecter.BuildMoodAnalysis(className, constructorName, message);

            //Assert
            expectedInstance.Equals(actualInstance);
        }
Beispiel #5
0
        public void TestSetFieldValue_NullMessage_ThrowExceptionNullMessage()
        {
            //Arrange
            string fieldName = "_message";
            string message   = null;
            string expected  = "Message should not be null";
            string actual;

            //Add
            try
            {
                actual = MoodAnalysisReflecter.SetFieldValue(fieldName, message);
            }
            catch (MoodAnalyserException e)
            {
                actual = e.Message;
            }

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public void TestSetFieldValue_WrongFieldName_ThrowExceptionFieldNotFound()
        {
            //Arrange
            string fieldName = "wrongField";
            string message   = "he is happy";
            string expected  = "Field not found";
            string actual;

            //Add
            try
            {
                actual = MoodAnalysisReflecter.SetFieldValue(fieldName, message);
            }
            catch (MoodAnalyserException e)
            {
                actual = e.Message;
            }

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        public void TestInvokeMoodAnalysis_WrongMethodName_ThrowMethodNotFoundException()
        {
            //Arrange
            string methodName = "AnalyseMoodWrongName";
            string message    = "he is sad";
            string expected   = "Method not found";
            string actual;

            //Add
            try
            {
                actual = MoodAnalysisReflecter.InvokeMoodAnalysis(methodName, message);
            }
            catch (MoodAnalyserException e)
            {
                actual = e.Message;
            }

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #8
0
        public void TestMoodAnalysisBuilder_WrongConstructorName_ThrowConstructorNotFoundException()
        {
            //Arrange
            string className       = "MoodAnalyser";
            string constructorName = "Wrong" + className;
            string expected        = "Constructor not found";
            string actual;

            //Add
            try
            {
                object actualInstance = MoodAnalysisReflecter.BuildMoodAnalysis(className, constructorName);
                actual = actualInstance.ToString();
            }
            catch (MoodAnalyserException e)
            {
                actual = e.Message;
            }

            //Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void TestParameterizedMoodAnalysisBuilder_WrongClassName_ThrowClassNotFoundException()
        {
            //Arrange
            string className       = "MoodAnalyserWrongName";
            string constructorName = className;
            string message         = "She is happy";
            string expected        = "Class not found";
            string actual;

            //Add
            try
            {
                object actualInstance = MoodAnalysisReflecter.BuildMoodAnalysis(className, constructorName, message);
                actual = actualInstance.ToString();
            }
            catch (MoodAnalyserException e)
            {
                actual = e.Message;
            }

            //Assert
            Assert.AreEqual(expected, actual);
        }