public void Formats_content_correctly()
 {
     //Arrange
     var sut = CreateSut();
     var message = new Message<string>("msg123", 21.November(2015).At(23, 45, 11, 456));
     //Act
     sut.Handle(message);
     //Assert
     FileSystem.Received().EnsurePathAndSave(dir: Arg.Any<string>(), fileName: Arg.Any<string>(),
         content: "msg123 2015-11-21-23-45-11-456");
 }
 public void Handle(Message msg)
 {
     var m = msg as Message<string>;
     if (m == null)
         throw new InvalidOperationException("I can handle only strings for now. Refactor me to use a message dispatcher");
     try
     {
         fileSystem.EnsurePathAndSave(GetDir(m), GetFileName(m), GetContent(m));
     }
     catch (Exception ex)
     {
         //swallowing as an individual failure mustn't shut down the processor
         Console.WriteLine($"Persisting failed with {ex.GetType().Name} - {ex.Message}");
     }
 }
 private string GetContent(Message<string> msg) =>
     Smart.Format(settings.ContentFormat, msg);
 private string GetFileName(Message<string> msg) =>
     Smart.Format(settings.FileNameFormat, msg);
 private string GetDir(Message<string> msg) => 
     Path.Combine(settings.RootDirectory,Smart.Format(settings.DirectoryFormat, msg));