<commit_before>﻿using System;
using System.Linq;
using Banzai.Logging;
using Serilog;
using NUnit.Framework;
using FluentAssertions;
using Serilog.Events;
using Serilog.Formatting.Display;

namespace Banzai.Serilog.Test
{
    [TestFixture]
    public class WhenWritingToLog
    {
        private TestSink _target;

        [SetUp]
        public void Setup()
        {
            _target = new TestSink(new MessageTemplateTextFormatter("${message}", null));

            Log.Logger = new LoggerConfiguration()
                .WriteTo.Sink(_target, LogEventLevel.Verbose)
                .CreateLogger();

            LogWriter.SetFactory(new SerilogWriterFactory());
            _target.Logs.Clear();
        }

        [Test]
        public void Can_Write_Fatal_With_Exception()
        {
        
            LogWriter.GetLogger(this).Fatal("Testing Fatal with exception.", new Exception("Test Exception"));
            _target.Logs.Any().Should().BeTrue();
            
        }

        [Test]
        public void Can_Write_Fatal_Without_Exception()
        {<commit_msg>Added serilog support<commit_after>﻿using System;
using System.Linq;
using Banzai.Logging;
using Serilog;
using NUnit.Framework;
using FluentAssertions;
using Serilog.Formatting.Display;

namespace Banzai.Serilog.Test
{
    [TestFixture]
    public class WhenWritingToLog
    {
        private TestSink _target;

        [SetUp]
        public void Setup()
        {
            _target = new TestSink(new MessageTemplateTextFormatter("${message}", null));

            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Verbose()
                .WriteTo.Sink(_target)
                .CreateLogger();

            LogWriter.SetFactory(new SerilogWriterFactory());
            _target.Logs.Clear();
        }

        [Test]
        public void Can_Write_Fatal_With_Exception()
        {
        
            LogWriter.GetLogger(this).Fatal("Testing Fatal with exception.", new Exception("Test Exception"));
            _target.Logs.Any().Should().BeTrue();
            
        }

        [Test]
        public void Can_Write_Fatal_Without_Exception()
        {
{'fraction_non_alphanumeric': 0.09726725335803613, 'fraction_numerical': 0.0, 'mean_word_length': 2.190546528803545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '928792', 'n_tokens_mistral': 609, 'n_tokens_neox': 592, 'n_words': 118}