public void ReadReadsFromCache(
            string shouldBeCached,
            string backDoorMessage)
        {
            var fileStore = new MessageStore(new DirectoryInfo(Environment.CurrentDirectory));

            fileStore.Save(55, shouldBeCached);
            fileStore.Read(55);
            var file = fileStore.GetFileInfo(55);

            File.WriteAllText(file.FullName, backDoorMessage);

            var actual = fileStore.Read(55);

            Assert.Equal(shouldBeCached, actual.Single());
        }
        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)));
        }
        public void ReadNonExistingMessageLogsCorrectDebugInformation()
        {
            var spy = new SpySink();

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

            fileStore.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)));
        }