예제 #1
0
        public void WhenLoggingOptionsAreNotSetLogLevelIsInformation()
        {
            var args       = this.options.ToArray();
            var results    = Parser.Default.ParseArguments <BaseOptions>(args);
            var logOptions = results.As <Parsed <BaseOptions> >();
            var command    = new BaseCommandMock(logOptions.Value);
            var logger     = command.Logger;

            logger.IsEnabled(LogLevel.Debug).Should().BeFalse();
            logger.IsEnabled(LogLevel.Information).Should().BeTrue();
        }
예제 #2
0
        public void WhenLoggingOptionsAreSetToVerboseLogLevelIsTrace()
        {
            this.options.Add("-v");
            var args       = this.options.ToArray();
            var results    = Parser.Default.ParseArguments <BaseOptions>(args);
            var logOptions = results.As <Parsed <BaseOptions> >();
            var command    = new BaseCommandMock(logOptions.Value);
            var logger     = command.Logger;

            logger.IsEnabled(LogLevel.Trace).Should().BeTrue();
        }
예제 #3
0
        public void WriteTrucatesFile()
        {
            var path = Path.GetRandomFileName();

            File.WriteAllText(path, string.Concat(string.Empty, Enumerable.Repeat("!", 1000)));
            BaseCommandMock.Write(path, 42);
            var content = File.ReadAllText(path);
            var json    = JToken.Parse(content);

            json.Type.Should().Be(JTokenType.Integer);
            json.Value <int>().Should().Be(42);
        }