public void MalformedContentTypeThrows() { Assert.Throws <FormatException>( () => new EventData(Uuid.NewUuid(), "-", Array.Empty <byte>(), contentType: "application")); }
protected static EventData CreateLinkToEvent(string originalStreamName, StreamRevision originalRevision) => new EventData(Uuid.NewUuid(), SystemEventTypes.LinkTo, Helper.UTF8NoBom.GetBytes($"{originalRevision.ToInt64()}@{originalStreamName}"));
protected static EventData CreateTestEvent(int index, string type) => new EventData(Uuid.NewUuid(), type, Encoding.UTF8.GetBytes($@"{{""x"":{index}}}"));
public void Equality() { var sut = Uuid.NewUuid(); Assert.Equal(Uuid.FromGuid(sut.ToGuid()), sut); }
private async ValueTask <IWriteResult> AppendInternal(BatchAppendReq.Types.Options options, IEnumerable <EventData> events, CancellationToken cancellationToken) { var batchSize = 0; var correlationId = Uuid.NewUuid(); var correlationIdDto = correlationId.ToDto(); var complete = _pendingRequests.GetOrAdd(correlationId, new TaskCompletionSource <IWriteResult>()); foreach (var appendRequest in GetRequests()) { await _channel.Writer.WriteAsync(appendRequest, cancellationToken).ConfigureAwait(false); } return(await complete.Task.ConfigureAwait(false)); IEnumerable <BatchAppendReq> GetRequests() { bool first = true; var proposedMessages = new List <BatchAppendReq.Types.ProposedMessage>(); foreach (var @event in events) { var proposedMessage = new BatchAppendReq.Types.ProposedMessage { Data = ByteString.CopyFrom(@event.Data.Span), CustomMetadata = ByteString.CopyFrom(@event.Metadata.Span), Id = @event.EventId.ToDto(), Metadata = { { Constants.Metadata.Type, @event.Type }, { Constants.Metadata.ContentType, @event.ContentType } } }; proposedMessages.Add(proposedMessage); if ((batchSize += proposedMessage.CalculateSize()) < _settings.OperationOptions.BatchAppendSize) { continue; } yield return(new BatchAppendReq { ProposedMessages = { proposedMessages }, CorrelationId = correlationIdDto, Options = first ? options : null }); first = false; proposedMessages.Clear(); batchSize = 0; } yield return(new BatchAppendReq { ProposedMessages = { proposedMessages }, IsFinal = true, CorrelationId = correlationIdDto, Options = first ? options : null }); } }
public void ToFormattedStringProducesExpectedResult() { var sut = Uuid.NewUuid(); Assert.Equal(sut.ToGuid().ToString("n"), sut.ToString("n")); }
public void ArgumentNullException() { var ex = Assert.Throws <ArgumentNullException>(() => Uuid.Parse(null)); Assert.Equal("value", ex.ParamName); }
public void InequalityOperator() { var sut = Uuid.NewUuid(); Assert.True(Uuid.NewUuid() != sut); }
public void EqualityOperator() { var sut = Uuid.NewUuid(); Assert.True(Uuid.FromGuid(sut.ToGuid()) == sut); }
public void Inequality() { var sut = Uuid.NewUuid(); Assert.NotEqual(Uuid.NewUuid(), sut); }