public async Task Should_generate_the_folder_and_file() { var property = await _repository.PutString("Hello, World."); Console.WriteLine(property.Address); Console.WriteLine("Path: {0}", Path.Combine(property.Address.Segments.SelectMany(x => x.Split(new [] { ':' })).ToArray())); }
public async Task Should_properly_load() { _completed = SubscribeHandler <RoutingSlipCompleted>(); _faulted = SubscribeHandler <RoutingSlipFaulted>(); _activityCompleted = SubscribeHandler <RoutingSlipActivityCompleted>(); _trackingNumber = NewId.NextGuid(); var builder = new RoutingSlipBuilder(_trackingNumber); builder.AddSubscription(Bus.Address, RoutingSlipEvents.All); ActivityTestContext testActivity = GetActivityContext <SetLargeVariableActivity>(); builder.AddActivity(testActivity.Name, testActivity.ExecuteUri, new { Key = "Name", Value = await _repository.PutString("Frank"), }); await Bus.Execute(builder.Build()); await Task.WhenAny(_completed, _faulted); if (_faulted.IsCompleted) { Console.WriteLine(string.Join(",", _faulted.Result.Message.ActivityExceptions.Select(x => x.ExceptionInfo.Message))); } Assert.That(_completed.Status, Is.EqualTo(TaskStatus.RanToCompletion)); }
async Task <MessageData <TValue> > Put(PipeContext context, Task <TValue> valueTask) { var repository = _repository; if (repository != null || context.TryGetPayload(out repository)) { TimeSpan?timeToLive = default; if (context.TryGetPayload(out SendContext sendContext) && sendContext.TimeToLive.HasValue) { timeToLive = sendContext.TimeToLive; } if (timeToLive.HasValue && MessageDataDefaults.ExtraTimeToLive.HasValue) { timeToLive += MessageDataDefaults.ExtraTimeToLive; } if (!timeToLive.HasValue && MessageDataDefaults.TimeToLive.HasValue) { timeToLive = MessageDataDefaults.TimeToLive.Value; } var value = await valueTask.ConfigureAwait(false); if (value is string stringValue) { MessageData <string> messageData = timeToLive.HasValue ? await _repository.PutString(stringValue, timeToLive.Value, context.CancellationToken).ConfigureAwait(false) : await _repository.PutString(stringValue, context.CancellationToken).ConfigureAwait(false); return((MessageData <TValue>)messageData); } if (value is byte[] bytesValue) { MessageData <byte[]> messageData = timeToLive.HasValue ? await _repository.PutBytes(bytesValue, timeToLive.Value, context.CancellationToken).ConfigureAwait(false) : await _repository.PutBytes(bytesValue, context.CancellationToken).ConfigureAwait(false); return((MessageData <TValue>)messageData); } if (value is Stream streamValue) { MessageData <Stream> messageData = timeToLive.HasValue ? await _repository.PutStream(streamValue, timeToLive.Value, context.CancellationToken).ConfigureAwait(false) : await _repository.PutStream(streamValue, default, context.CancellationToken).ConfigureAwait(false);
async Task <MessageData <TValue> > Put(PipeContext context, Task <TValue> valueTask) { var repository = _repository; if (repository != null || context.TryGetPayload(out repository)) { TimeSpan?timeToLive = default; if (context.TryGetPayload(out SendContext sendContext) && sendContext.TimeToLive.HasValue) { timeToLive = sendContext.TimeToLive; } if (timeToLive.HasValue && MessageDataDefaults.ExtraTimeToLive.HasValue) { timeToLive += MessageDataDefaults.ExtraTimeToLive; } if (!timeToLive.HasValue && MessageDataDefaults.TimeToLive.HasValue) { timeToLive = MessageDataDefaults.TimeToLive.Value; } var value = await valueTask.ConfigureAwait(false); if (value is string stringValue) { MessageData <string> messageData = timeToLive.HasValue ? await _repository.PutString(stringValue, timeToLive.Value, context.CancellationToken).ConfigureAwait(false) : await _repository.PutString(stringValue, context.CancellationToken).ConfigureAwait(false); return((MessageData <TValue>)messageData); } if (value is byte[] bytesValue) { MessageData <byte[]> messageData = timeToLive.HasValue ? await _repository.PutBytes(bytesValue, timeToLive.Value, context.CancellationToken).ConfigureAwait(false) : await _repository.PutBytes(bytesValue, context.CancellationToken).ConfigureAwait(false); return((MessageData <TValue>)messageData); } throw new MessageDataException("Unsupported message data type: " + TypeMetadataCache <TValue> .ShortName); } throw new MessageDataException("Message data repository was not available: " + TypeMetadataCache <TValue> .ShortName); }