示例#1
0
 public void NullLoggerThrowsException()
 {
     FormatterArgs item = new FormatterArgs(new FormatterArgs.CreateOptions
     {
         Logger = null
     });
 }
示例#2
0
        private static object InvokeFormatter(FormatterArgs formatterArgs, PropertyArgs propertyArgs)
        {
            var source = Activator.CreateInstance(formatterArgs.Type);

            formatterArgs.Method.Invoke(source, new object[] { propertyArgs });

            var formatterSource = source as Formatter;

            return(formatterSource.IsFormatted ? formatterSource.FormattedObject : null);
        }
示例#3
0
        public void CreateOptionsConstructorUpdatesProperties()
        {
            var options = new FormatterArgs.CreateOptions
            {
                State        = new { },
                Exception    = new Exception(),
                DefaultValue = $"Log-{Guid.NewGuid()}",
                Logger       = new Logger()
            };

            FormatterArgs item = new FormatterArgs(options);

            Assert.AreSame(options.State, item.State);
            Assert.AreSame(options.Exception, item.Exception);
            Assert.AreEqual(options.DefaultValue, item.DefaultValue);
        }
        private void SetParameter()
        {
            if (!IsValid())
            {
                return;
            }

            if (_nameFormatter is SingleParameterNameFormatter)
            {
                SingleParameterNameArgs args = new SingleParameterNameArgs(int.Parse(TextItemCount));
                args.IncrementValue = int.Parse(TextIncrement);
                args.StartValue     = int.Parse(TextStartNumber);
                var splitTuple = GetSplitValue();
                args.PrefixValue  = splitTuple.Item1;
                args.PostfixValue = splitTuple.Item2;
                _args             = args;
            }
            else
            {
                // TODO
            }
        }
示例#5
0
 public void SetNameFormatter(NameFormatter nameFormatter, FormatterArgs args)
 {
     _nameFormatter = nameFormatter;
     _args          = args;
 }
示例#6
0
 public void NullCreateOptionsThrowsException()
 {
     FormatterArgs item = new FormatterArgs(null);
 }
示例#7
0
        public static Plan CreatePlan(Type type, DateTime startDate, NameFormatter nameFormatter, FormatterArgs args)
        {
            Plan plan      = (Plan)Activator.CreateInstance(type, startDate);
            var  itemNames = nameFormatter.Format(args);

            foreach (string itemName in itemNames)
            {
                plan.GenerateItem(itemName);
            }

            return(plan);
        }