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(); }
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(); }
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); }