public void EmptyMapper_HasRegexGroupAttribute_ReturnsFalse()
        {
            // arrange & act
            var mapper = new RegexGroupMapper(-1, null);

            // assert
            Assert.IsFalse(mapper.HasRegexGroupAttribute);
        }
        public void Mapper_RegexGroupIndexGreaterEqualZero_ReturnsTrue()
        {
            // arrange & act
            var mapper = new RegexGroupMapper(1, null);

            // assert
            Assert.IsTrue(mapper.HasRegexGroupAttribute);
        }
        public void EmptyMapper_HasManipulationFunction_ReturnsFalse()
        {
            // arrange & act
            var mapper = new RegexGroupMapper(-1, null);

            // assert
            Assert.IsFalse(mapper.HasManipulateFunction);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Call user defined output manipulation functions.
        /// </summary>
        /// <param name="value">Group value to be manipulated with given functions.</param>
        /// <param name="group">Group containing the manipulation functions.</param>
        /// <returns>Manipulated value</returns>
        private string ProcessOutputManipulation(string value, RegexGroupMapper group)
        {
            // manipulate value if possible
            if (group.HasManipulateFunction)
            {
                var manipulationInstance = group.RegexManipulationInstance;
                var manipulationMethod   = manipulationInstance.GetType().GetMethod("Invoke");
                value = manipulationMethod.Invoke(manipulationInstance, new object[] { value }) as string;
            }

            return(value);
        }
        public void Mapper_TrimFunction_IsSameInstance()
        {
            // arrange
            var instance = new TrimOutputManipulation();

            // act
            var mapper = new RegexGroupMapper(1, instance);

            // assert
            Assert.IsTrue(mapper.HasManipulateFunction);
            Assert.IsInstanceOf <TrimOutputManipulation>(mapper.RegexManipulationInstance);
        }