private static async Task HandleUnhandledObjectOfTypeAsync <TObject>(
            FileStandardStream stream,
            string concern,
            HandleRecordAsyncSpecificProtocolBase <TObject> handler)
        {
            var streamRecordHandlingProtocol = stream.GetStreamRecordHandlingProtocols <TObject>();

            var recordToHandle = await streamRecordHandlingProtocol.ExecuteAsync(new TryHandleRecordOp <TObject>(concern));

            if (recordToHandle != null)
            {
                try
                {
                    var handleRecordOp = new HandleRecordOp <TObject>(recordToHandle);

                    await handler.ExecuteAsync(handleRecordOp);

                    stream.GetStreamRecordHandlingProtocols().Execute(new CompleteRunningHandleRecordOp(recordToHandle.InternalRecordId, concern));
                }
                catch (SelfCancelRunningExecutionException ex)
                {
                    stream.GetStreamRecordHandlingProtocols().Execute(new SelfCancelRunningHandleRecordOp(recordToHandle.InternalRecordId, concern, ex.Details));
                }
                catch (Exception ex)
                {
                    stream.GetStreamRecordHandlingProtocols().Execute(new FailRunningHandleRecordOp(recordToHandle.InternalRecordId, concern, ex.ToString()));

                    throw;
                }
            }
        }
        private static Streams BuildStreamsAsync(
            string streamRootDirectoryPath)
        {
            var serializerRepresentation = new SerializerRepresentation(SerializationKind.Json, typeof(IntegrationTestJsonSerializationConfiguration).ToRepresentation());
            var serializerFactory        = new JsonSerializerFactory();
            var resourceLocatorProtocols = new SingleResourceLocatorProtocols(new FileSystemDatabaseLocator(streamRootDirectoryPath));

            var clientOperationStream   = new FileStandardStream("client-operation", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var notificationEventStream = new FileStandardStream("notification-event", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var notificationSagaStream  = new FileStandardStream("notification-saga", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var emailOperationStream    = new FileStandardStream("email-operation", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var emailEventStream        = new FileStandardStream("email-event", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var slackOperationStream    = new FileStandardStream("slack-operation", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);
            var slackEventStream        = new FileStandardStream("slack-event", serializerRepresentation, SerializationFormat.String, serializerFactory, resourceLocatorProtocols);

            clientOperationStream.Execute(new StandardCreateStreamOp(clientOperationStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            notificationEventStream.Execute(new StandardCreateStreamOp(notificationEventStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            notificationSagaStream.Execute(new StandardCreateStreamOp(notificationSagaStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            emailOperationStream.Execute(new StandardCreateStreamOp(emailOperationStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            emailEventStream.Execute(new StandardCreateStreamOp(emailEventStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            slackOperationStream.Execute(new StandardCreateStreamOp(slackOperationStream.StreamRepresentation, ExistingStreamStrategy.Skip));
            slackEventStream.Execute(new StandardCreateStreamOp(slackEventStream.StreamRepresentation, ExistingStreamStrategy.Skip));

            var result = new Streams
            {
                ClientOperationStream   = clientOperationStream,
                NotificationEventStream = notificationEventStream,
                NotificationSagaStream  = notificationSagaStream,
                EmailOperationStream    = emailOperationStream,
                EmailEventStream        = emailEventStream,
                SlackOperationStream    = slackOperationStream,
                SlackEventStream        = slackEventStream,
            };

            return(result);
        }