示例#1
0
        public void CheckForNotMatchingPVS_Should_ReturnTheExpectedListOfUnityTestBDDErrorObjects_Given_TheParametersIndexesAndADynamicComponentWithoutACorrespondingParametersValuesStorages()
        {
            Component component = UnitTestUtility.CreateComponent <ChosenMethodsCheckerTestFirstDynamicComponent>();

            Component[] components = new Component[1] {
                component
            };
            MethodInfo methodInfo = component.GetType().GetMethod("GivenMethod");

            string[] chosenMethods = new string[1] {
                "ChosenMethodsCheckerTestFirstDynamicComponent.GivenMethod"
            };
            string[] parametersIndexes = new string[1] {
                ";System.String,ChosenMethodsCheckerTestFirstDynamicComponent.GivenMethod.stringParam.,otherPVS.Array.data[0];"
            };
            ChosenMethodsChecker checkForErrors = new ChosenMethodsChecker();

            List <UnityTestBDDError> result = checkForErrors.CheckForNotMatchingPVS <GivenBaseAttribute>(chosenMethods, parametersIndexes, components);

            string expectedMessage = "The ParametersValuesStorage field otherPVS for the parameter ChosenMethodsCheckerTestFirstDynamicComponent.GivenMethod.stringParam. is not found in Given methods at position 1";

            Assert.AreEqual(expectedMessage, result[0].Message, "The method CheckForNotMatchingPVS doesn't resturn the right message");
            Assert.That(component.Equals(result[0].Component), "The method CheckForNotMatchingPVS doesn't resturn the right Component");
            Assert.That(methodInfo.Equals(result[0].MethodMethodInfo), "The method CheckForNotMatchingPVS doesn't resturn the right MethodInfo");
            Assert.AreEqual(typeof(GivenBaseAttribute), result[0].StepType, "The method CheckForNotMatchingPVS doesn't resturn the right StepType");
            Assert.AreEqual(0, result[0].Index, "The method CheckForNotMatchingPVS doesn't resturn the right method index");
        }
示例#2
0
        public void CheckForNotMatchingPVS_Should_ReturnTheExpectedListOfUnityTestBDDErrorObjects_Given_TheParametersIndexesAndADynamicComponentWithTheCorrespondingParametersValuesStorages()
        {
            Component component = UnitTestUtility.CreateComponent <ChosenMethodsCheckerTestFirstDynamicComponent>();

            Component[] components = new Component[1] {
                component
            };
            ArrayStorageUtilities arrayStorageUtilities = new ArrayStorageUtilities();
            FieldInfo             stringPVS             = arrayStorageUtilities.GetArrayStorageFieldInfoByType(component, typeof(string));
            Array array = new string[1];

            stringPVS.SetValue(component, array);
            string[] chosenMethods = new string[1] {
                "ChosenMethodsCheckerTestFirstDynamicComponent.GivenMethod"
            };
            string[] parametersIndexes = new string[1] {
                ";System.String,ChosenMethodsCheckerTestFirstDynamicComponent.GivenMethod.stringParamWrongName.,stringPVS.Array.data[0];"
            };
            ChosenMethodsChecker     checkForErrors = new ChosenMethodsChecker();
            List <UnityTestBDDError> result         = checkForErrors.CheckForNotMatchingPVS <GivenBaseAttribute>(chosenMethods, parametersIndexes, components);

            Assert.AreEqual(0, result.Count, "The method CheckForNotMatchingPVS doesn't check properly");
        }