LCOV - code coverage report
Current view: top level - Cqrs.EventStore/Bus - EventStoreUtilities.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 5 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using System.Text;
       2             : using EventStore.ClientAPI;
       3             : 
       4             : namespace Cqrs.EventStore.Bus
       5             : {
       6             :         public static class EventStoreUtilities
       7           0 :         {
       8           0 :                 public static string PositionToFormattedString(Position position)
       9             :                 {
      10             :                         return position.CommitPosition + "/" + position.PreparePosition;
      11             :                 }
      12             : 
      13           0 :                 public static Position FormattedStringToPosition(string formattedPosition)
      14             :                 {
      15             :                         Position position = Position.End;
      16             : 
      17             :                         if (!string.IsNullOrEmpty(formattedPosition))
      18             :                         {
      19             :                                 string[] substrings = formattedPosition.Split('/');
      20             :                                 long commitPosition, preparePosition;
      21             :                                 if (long.TryParse(substrings[0], out commitPosition) &&
      22             :                                         long.TryParse(substrings[1], out preparePosition))
      23             :                                 {
      24             :                                         position = new Position(commitPosition, preparePosition);
      25             :                                 }
      26             :                                 else
      27             :                                 {
      28             :                                         throw new InvalidLastEventProcessedException(formattedPosition);
      29             :                                 }
      30             :                         }
      31             : 
      32             :                         return position;
      33             :                 }
      34             : 
      35           0 :                 public static byte[] StringToByteArray(string value)
      36             :                 {
      37             :                         byte[] rawEventData = Encoding.UTF8.GetBytes(value);
      38             :                         return rawEventData;
      39             :                 }
      40             : 
      41           0 :                 public static string ByteArrayToString(byte[] value)
      42             :                 {
      43             :                         return Encoding.UTF8.GetString(value);
      44             :                 }
      45             :         }
      46             : }

Generated by: LCOV version 1.10