public void ReadExistingMessageLogsCorrectDebugInformation(string message)
        {
            var fileStore = new MessageStore(new DirectoryInfo(Environment.CurrentDirectory));

            fileStore.Save(53, message);
            var spy = new SpySink();

            Log.Logger = new LoggerConfiguration().WriteTo.Sink(spy).MinimumLevel.Debug().CreateLogger();

            fileStore.Read(53);

            Assert.True(spy.Events
                        .Where(le => le.MessageTemplate.Text == "Reading message {id}.")
                        .SelectMany(le => le.Properties)
                        .Where(kvp => kvp.Key == "id")
                        .Select(kvp => kvp.Value)
                        .OfType <ScalarValue>()
                        .Any(sv => sv.Value.Equals(53)));
            Assert.True(spy.Events
                        .Where(le => le.MessageTemplate.Text == "Returning message {id}.")
                        .SelectMany(le => le.Properties)
                        .Where(kvp => kvp.Key == "id")
                        .Select(kvp => kvp.Value)
                        .OfType <ScalarValue>()
                        .Any(sv => sv.Value.Equals(53)));
        }
Ejemplo n.º 2
0
        public void SaveLogsInformation(string message)
        {
            var spy      = new SpySink();
            var logger   = new LoggerConfiguration().WriteTo.Sink(spy).CreateLogger();
            var msgStore = CreateMessageStore(logger);

            msgStore.Save(52, message);

            Assert.True(spy.Events
                        .SelectMany(le => le.Properties)
                        .Where(kvp => kvp.Key == "id")
                        .Select(kvp => kvp.Value)
                        .OfType <ScalarValue>()
                        .Any(sv => sv.Value.Equals(52)));
        }
        public void SaveLogsInformation(string message)
        {
            var spy = new SpySink();

            Log.Logger = new LoggerConfiguration().WriteTo.Sink(spy).CreateLogger();
            var fileStore = new MessageStore(new DirectoryInfo(Environment.CurrentDirectory));

            fileStore.Save(52, message);

            Assert.True(spy.Events
                        .SelectMany(le => le.Properties)
                        .Where(kvp => kvp.Key == "id")
                        .Select(kvp => kvp.Value)
                        .OfType <ScalarValue>()
                        .Any(sv => sv.Value.Equals(52)));
        }
Ejemplo n.º 4
0
        public void ReadNonExistingMessageLogsCorrectDebugInformation()
        {
            var spy      = new SpySink();
            var logger   = new LoggerConfiguration().WriteTo.Sink(spy).MinimumLevel.Debug().CreateLogger();
            var msgStore = CreateMessageStore(logger);

            msgStore.Read(54);

            Assert.True(spy.Events
                        .Where(le => le.MessageTemplate.Text == "No message {id} found.")
                        .SelectMany(le => le.Properties)
                        .Where(kvp => kvp.Key == "id")
                        .Select(kvp => kvp.Value)
                        .OfType <ScalarValue>()
                        .Any(sv => sv.Value.Equals(54)));
        }