static void Main(string[] args) { #region Initialize logger var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new System.IO.FileInfo("Log4Net.config")); log.Info("Application [FileParser] Start"); #endregion SequenceType sequenceType; int sequenceTypeString; IntRange range; #region Check input data sequenceTypeString = Parser.TryGetInt(args, SequenceTypeInputIndex, out ErrorCode errorCode); if (errorCode != ErrorCode.Void) { ConsoleShowError(errorCode); return; } if (!Enum.IsDefined(typeof(SequenceType), sequenceTypeString)) { log.Error(ErrorCode.InvalidParameter.ToString()); ConsoleShowError(ErrorCode.InvalidParameter, "SequenceType"); return; } else { sequenceType = (SequenceType)sequenceTypeString; } range = Parser.TryGetRange(args, out errorCode); if (errorCode != ErrorCode.Void) { ConsoleShowError(errorCode); return; } if (!Validator.IsNaturalNumber(range.Start) || !Validator.IsNaturalNumber(range.End) || !Validator.IsNaturalNumber(range.Count()) || !Validator.IsNumberInRange(range.End, 0, (sequenceType == SequenceType.Fibonacci) ? MaxForFibonacci : Int32.MaxValue)) { ConsoleShowError(ErrorCode.OverflowRange); return; } #endregion SequenceCalculator sequenceCalculator = new SequenceCalculator(SequenceFactory.Build(sequenceType)); sequenceCalculator.PrintGeneratedString(range, ','); Console.ReadKey(); log.Info("Application [FileParser] End"); }
public void Build_Fibonnaci_Positive(SequenceType sequenceType) { //arrange //act ISequence sequence = SequenceFactory.Build(sequenceType); //assert Assert.NotNull(sequence); }
public void Build_UndefinedType_Negative() { //arrange //act ISequence sequence = null; //assert Assert.Throws <ArgumentException>(() => sequence = SequenceFactory.Build(0)); }