コード例 #1
0
ファイル: LoggingExtensionsSpec.cs プロジェクト: TAGC/TimeIt
        internal void TimeIt_Should_Throw_Exception_If_Log_Template_Is_Invalid()
        {
            var timer    = ConfigureMockTimer(0);
            var timeit   = new MockTimeIt(timer);
            var args     = new object[] { "Too", "Few", "Args" };
            var template = "{And} {Too} {Many} {Placeholders} {Elapsed}";

            Should.Throw <FormatException>(() => timeit.Then.Log(_logger, template, args).Dispose());
        }
コード例 #2
0
        internal void TimeIt_Should_Be_Configurable_To_Throw_On_Timeout(int elapsed, int timeout, bool shouldThrow)
        {
            var timer  = ConfigureMockTimer(elapsed);
            var timeit = new MockTimeIt(timer);

            if (shouldThrow)
            {
                Should.Throw <TimeoutException>(() => timeit.Then.ThrowIfLongerThan(timeout).Dispose());
            }
            else
            {
                Should.NotThrow(() => timeit.Then.ThrowIfLongerThan(timeout).Dispose());
            }
        }
コード例 #3
0
ファイル: LoggingExtensionsSpec.cs プロジェクト: TAGC/TimeIt
        internal void TimeIt_Should_Be_Configurable_To_Log_Elapsed_Time(
            int elapsedTime,
            LogLevel logLevel,
            string template,
            object[] args,
            string expectedLogPattern)
        {
            var timer  = ConfigureMockTimer(elapsedTime);
            var timeit = new MockTimeIt(timer);

            string log = null;

            _logger.GeneratedLog += (s, e) => log = e.Log;
            timeit.Then.Log(_logger, logLevel, template, args).Dispose();

            log.ShouldMatch(expectedLogPattern);
        }
コード例 #4
0
        internal void TimeIt_Should_Be_Configurable_To_Do_Nothing()
        {
            var timeit = new MockTimeIt(Mock.Of <IRestartableTimer>());

            Should.NotThrow(() => timeit.Then.DoNothing());
        }