Пример #1
0
        /// <summary>
        ///     Now try to understand this scenario, to call this method we need to pass these parameters.
        ///     Now there is no way to understand what these parameters are or how these parameters needs to be passed.
        ///     To find that we need to find Invoking Expression of "BusinessMethodDependency" and detects all it's parameter
        ///     initialize recursively.
        ///     To find dependencies we need to find the method "BusinessMethod" programmatically not hard coded fashion.
        ///     To test this method, we need to 2 setup methods
        ///         1.  Setup of Parameters from "BusinessMethod".
        ///         2.  Setup of inner properties (IntThrows, IntStaticThrows, PubliceByteProp, PublicStringProp), fields,
        ///         methods (ArgumentNullException, SomethingDynamicComplex, ThrowException,
        ///         BusinessLogicExampleOfSameplemethod, BusinessLogicExampleOfSamepleMethodString,
        ///         SampleMethod, SampleMethodString, ThrowException("Needs to be covered" + intX + y))
        /// </summary>
        /// <param name="somethingComplex"></param>
        /// <param name="sample"></param>
        /// <param name="classWithProperties"></param>
        /// <param name="classWithMethods"></param>
        /// <param name="required"></param>
        /// <param name="prep"></param>
        public void BusinessMethodDependency(dynamic somethingComplex,
                                             dynamic sample,
                                             ClassWithProperties classWithProperties,
                                             ClassWithMethods classWithMethods,
                                             IRequired required,
                                             IRequiredPrep prep)
        {
            Utility.ArgumentNullException("Testing"); // this method needs to be Faked
            somethingComplex.SomethingDynamicComplex();
            var x = classWithProperties.PubliceByteProp;
            var y = classWithProperties.PublicStringProp;

            Utility.ThrowException(); // this method needs to be Faked

            var classWithBusinessLogic = new ClassWithBusinessLogic(required);

            classWithBusinessLogic.BusinessLogicExampleOfSameplemethod();
            y = classWithBusinessLogic.BusinessLogicExampleOfSamepleMethodString() + x;

            var classWithBusinessLogic2 = new ClassWithBusinessLogic2();

            classWithBusinessLogic2.SampleMethodString();

            var requiredConcrete = new Required();

            requiredConcrete.SampleMethod(prep);
            requiredConcrete.SampleMethodString(prep);

            var intX = (int)sample + 5 + IntThrows + IntStaticThrows;

            Utility.ThrowException("Needs to be covered" + intX + y); // this method needs to be Faked and covered
        }