/// <summary> /// Creates the underlying <see cref="HeaderCollection"/> dictionary. /// </summary> /// <param name="headers">The set of custom message headers.</param> protected virtual Dictionary <String, String> CreateHeaderDictionary(IEnumerable <Header> headers) { var result = headers == null ? new Dictionary <String, String>() : headers.ToDictionary(header => header.Name, header => header.Value); result[Header.Timestamp] = SystemTime.GetTimestamp().ToString(DateTimeFormat.RoundTrip); if (!result.ContainsKey(Header.Origin)) { result[Header.Origin] = HostServer; } return(result); }
/// <summary> /// Returns the creation timestamp or the current system time if not set. /// </summary> public DateTime GetTimestamp() { String value; if (!TryGetValue(Header.Timestamp, out value) || value == null) { return(SystemTime.GetTimestamp()); } DateTime timestamp; return(DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out timestamp) ? timestamp : SystemTime.GetTimestamp()); }
public void WillReturnDistinctStreamIds() { EventStore.Purge(); for (var i = 1; i <= 5; i++) { var streamId = Guid.NewGuid(); EventStore.Save(new Commit(null, SystemTime.GetTimestamp(), Guid.NewGuid(), streamId, 1, HeaderCollection.Empty, EventCollection.Empty)); EventStore.Save(new Commit(null, SystemTime.GetTimestamp(), Guid.NewGuid(), streamId, 2, HeaderCollection.Empty, EventCollection.Empty)); } Assert.Equal(5, EventStore.GetStreams().Count()); }