コード例 #1
0
        /// <summary>Initializes a new instance of the <see cref="FilteringLogger"/> class.</summary>
        /// <param name="wrappedLogger">The logger to redirect the output. Cannot be null.</param>
        /// <param name="logFilter">The log filtering mode.</param>
        public FilteringLogger([NotNull] ILogger wrappedLogger, LogFilter logFilter)
        {
            Code.NotNull(wrappedLogger, nameof(wrappedLogger));
            DebugEnumCode.Defined(logFilter, nameof(logFilter));

            WrappedLogger = wrappedLogger;
            LogFilter     = logFilter;
        }
コード例 #2
0
ファイル: Analysis.cs プロジェクト: lovaya/CodeJam
        /// <summary>Initializes a new instance of the <see cref="Analysis"/> class.</summary>
        /// <param name="config">The config.</param>
        /// <param name="messageSource">Source for the messages.</param>
        public Analysis([NotNull] IConfig config, MessageSource messageSource)
        {
            Code.NotNull(config, nameof(config));
            DebugEnumCode.Defined(messageSource, nameof(messageSource));

            RunState      = CompetitionCore.RunState[config];
            MessageSource = messageSource;
        }
コード例 #3
0
ファイル: MetricValueColumn.cs プロジェクト: lovaya/CodeJam
        /// <summary>Initializes a new instance of the <see cref="MetricValueColumn"/> class.</summary>
        /// <param name="name">The  column name.</param>
        /// <param name="metric">The metric information.</param>
        /// <param name="kind">The kind of value to display.</param>
        public MetricValueColumn([CanBeNull] string name, [NotNull] MetricInfo metric, Kind kind)
        {
            DebugEnumCode.Defined(kind, nameof(kind));
            _kind = kind;

            ColumnName         = name ?? (metric.DisplayName + (kind == Kind.Mean ? "" : "-" + kind));
            Metric             = metric;
            PriorityInCategory = PriorityInCategoryStartValue;
        }
コード例 #4
0
        /// <summary>Initializes a new instance of the <see cref="Analysis"/> class.</summary>
        /// <param name="id">The identifier.</param>
        /// <param name="summary">The summary.</param>
        /// <param name="messageSource">Source for the messages.</param>
        public Analysis([NotNull] string id, [NotNull] Summary summary, MessageSource messageSource)
        {
            Code.NotNullNorEmpty(id, nameof(id));
            Code.NotNull(summary, nameof(summary));
            DebugEnumCode.Defined(messageSource, nameof(messageSource));

            Id            = id;
            Summary       = summary;
            RunState      = CompetitionCore.RunState[summary];
            MessageSource = messageSource;
        }
コード例 #5
0
        public void TestDebugDefined()
        {
#if DEBUG
            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => EnumCode.Defined(FileAccess.Write + 123, "arg00"));
            Assert.That(ex.Message, Does.Contain("arg00"));
            Assert.That(ex.Message, Does.Contain("Unexpected value"));
#else
            // ReSharper disable once InvocationIsSkipped
            Assert.DoesNotThrow(() => DebugEnumCode.Defined(FileAccess.Write + 123, "arg00"));
#endif

            // ReSharper disable once InvocationIsSkipped
            Assert.DoesNotThrow(() => DebugEnumCode.Defined(FileAccess.Write, "arg00"));
        }
コード例 #6
0
ファイル: Message.cs プロジェクト: lovaya/CodeJam
        /// <summary>Initializes a new instance of the <see cref="Message" /> class.</summary>
        /// <param name="runNumber">Number of the run the message belongs to.</param>
        /// <param name="runMessageNumber">Number of the message in the run.</param>
        /// <param name="elapsed">Time elapsed from the start of the benchmark.</param>
        /// <param name="messageSource">Source of the message.</param>
        /// <param name="messageSeverity">Severity of the message.</param>
        /// <param name="messageText">Text of the message.</param>
        /// <param name="hintText">Hints for the message.</param>
        public Message(
            int runNumber,
            int runMessageNumber,
            TimeSpan elapsed,
            MessageSource messageSource, MessageSeverity messageSeverity,
            [NotNull] string messageText,
            string hintText)
        {
            DebugCode.ValidCount(runNumber, nameof(runNumber));
            DebugCode.ValidCount(runMessageNumber, nameof(runMessageNumber));
            DebugCode.AssertArgument(elapsed > TimeSpan.Zero, nameof(messageSeverity), "Elapsed time should be positive.");
            DebugEnumCode.Defined(messageSource, nameof(messageSource));
            DebugEnumCode.Defined(messageSeverity, nameof(messageSeverity));
            Code.NotNullNorEmpty(messageText, nameof(messageText));

            RunNumber        = runNumber;
            RunMessageNumber = runMessageNumber;
            Elapsed          = elapsed;
            MessageSource    = messageSource;
            MessageSeverity  = messageSeverity;
            MessageText      = messageText;
            HintText         = hintText;
        }