Ejemplo n.º 1
0
        public void DefineIntro_Save_Method_With_No_Parameters_Call_With_Reflection_Exception_Thrown_Test()
        {
            // Arrange
            object[] parametersOutRanged = { null, null };
            var      defineIntro         = new DefineIntro();
            var      methodName          = "Save";

            // Act
            var saveMethodInfo1 = defineIntro.GetType().GetMethod(methodName);
            var saveMethodInfo2 = defineIntro.GetType().GetMethod(methodName);
            var returnType1     = saveMethodInfo1.ReturnType;
            var returnType2     = saveMethodInfo2.ReturnType;

            // Assert
            parametersOutRanged.ShouldNotBeNull();
            returnType1.ShouldNotBeNull();
            returnType2.ShouldNotBeNull();
            returnType1.ShouldBe(returnType2);
            defineIntro.ShouldNotBeNull();
            saveMethodInfo1.ShouldNotBeNull();
            saveMethodInfo2.ShouldNotBeNull();
            saveMethodInfo1.ShouldBe(saveMethodInfo2);
            Should.Throw <Exception>(actual: () => saveMethodInfo1.Invoke(defineIntro, parametersOutRanged));
            Should.Throw <Exception>(actual: () => saveMethodInfo2.Invoke(defineIntro, parametersOutRanged));
            Should.Throw <TargetParameterCountException>(actual: () => saveMethodInfo1.Invoke(defineIntro, parametersOutRanged));
            Should.Throw <TargetParameterCountException>(actual: () => saveMethodInfo2.Invoke(defineIntro, parametersOutRanged));
        }
Ejemplo n.º 2
0
        public void DefineIntro_Class_Invalid_Property_SurveyIDNotPresent_Access_Using_Reflexion_Doesnt_Throw_Exception_Test()
        {
            // Arrange
            const string propertyNameSurveyId = "SurveyIDNotPresent";
            var          defineIntro          = new DefineIntro();

            // Act , Assert
            Should.NotThrow(action: () => defineIntro.GetType().GetProperty(propertyNameSurveyId));
        }
Ejemplo n.º 3
0
        public void DefineIntro_Initialize_Method_With_No_Parameters_Call_With_Reflection_Test()
        {
            // Arrange
            var defineIntro = new DefineIntro();
            var methodName  = "Initialize";

            // Act
            var initializeMethodInfo1 = defineIntro.GetType().GetMethod(methodName);
            var initializeMethodInfo2 = defineIntro.GetType().GetMethod(methodName);
            var returnType1           = initializeMethodInfo1.ReturnType;
            var returnType2           = initializeMethodInfo2.ReturnType;

            // Assert
            defineIntro.ShouldNotBeNull();
            initializeMethodInfo1.ShouldNotBeNull();
            initializeMethodInfo2.ShouldNotBeNull();
            initializeMethodInfo1.ShouldBe(initializeMethodInfo2);
            returnType1.ShouldNotBeNull();
            returnType2.ShouldNotBeNull();
            returnType1.ShouldBe(returnType2);
            Should.NotThrow(action: () => initializeMethodInfo1.Invoke(defineIntro, null));
        }
Ejemplo n.º 4
0
        public void DefineIntro_ErrorMessage_Property_Is_Present_In_Class_As_Public_Test()
        {
            // Arrange
            const string propertyNameErrorMessage = "ErrorMessage";
            var          defineIntro  = new DefineIntro();
            var          propertyInfo = defineIntro.GetType().GetProperty(propertyNameErrorMessage);

            // Act
            var canRead = propertyInfo.CanRead;

            // Assert
            propertyInfo.ShouldNotBeNull();
            canRead.ShouldBeTrue();
        }