Ejemplo n.º 1
0
        /// <summary>
        /// Constructor (throws ArgumentException on invalid input)
        /// </summary>
        /// <param name="input">input object</param>
        /// <param name="caseSensitive">flag whether find matches with case sensitive or not (default to case insensitive)</param>
        public Algorithm(IInput input, IOverlapCalculator Table, bool caseSensitive = false)
        {
            try
            {
                if (input == null)
                {
                    throw new ArgumentNullException(Errors.InputWasNull);
                }

                if (!input.IsValid)
                {
                    throw new ArgumentException(Errors.InputWasInvalid);
                }

                if (Table == null)
                {
                    throw new ArgumentNullException(Errors.OvelapCalculatorWasNull);
                }

                this.Text            = input.Text;
                this.SubText         = input.SubText;
                this.PrefixTable     = Table.Compute();
                this.IsCaseSensitive = caseSensitive;
            }
            catch (Exception e)
            {
                Logger.Push("Error received while initializing the KMPAlgorithm class object : " + e.Message);
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor (throws ArgumentException on invalid input)
        /// </summary>
        /// <param name="input">input object</param>
        /// <param name="caseSensitive">flag whether find matches with case sensitive or not (default to case insensitive)</param>
        public Algorithm(IInput input, IOverlapCalculator Table, bool caseSensitive = false)
        {
            try
            {
                if (input == null)
                {
                    throw new ArgumentNullException(Errors.InputWasNull);
                }

                if (!input.IsValid)
                {
                    throw new ArgumentException(Errors.InputWasInvalid);
                }

                if (Table == null)
                {
                    throw new ArgumentNullException(Errors.OvelapCalculatorWasNull);
                }

                this.Text = input.Text;
                this.SubText = input.SubText;
                this.PrefixTable = Table.Compute();
                this.IsCaseSensitive = caseSensitive;
            }
            catch (Exception e)
            {
                Logger.Push("Error received while initializing the KMPAlgorithm class object : " + e.Message);
                throw;
            }
        }
Ejemplo n.º 3
0
 protected void SetUp()
 {
     prefixCalculator = Substitute.For <IOverlapCalculator>();
     input            = Substitute.For <IInput>();
     prefixCalculator.IsCaseSensitive.Returns(false);
 }