public void HigherVersionAfterLowerVersion() { var version1 = new EventVersion(1, 2, 2); var version2 = new EventVersion(2, 1, 1); Assert.Equal(1, version2.CompareTo(version1)); }
public void HigherItemAfterLowerItemInSameVersion() { var version1 = new EventVersion(1, 2, 1); var version2 = new EventVersion(1, 2, 2); Assert.Equal(1, version2.CompareTo(version1)); }
public void LowerItemBeforeHigherItemInSameVersion() { var version1 = new EventVersion(1, 2, 1); var version2 = new EventVersion(1, 2, 2); Assert.Equal(-1, version1.CompareTo(version2)); }
public void AlwaysReturnConsistentValue() { var version1 = new EventVersion(1, 1, 1); var version2 = new EventVersion(1, 1, 1); Assert.Equal(version1.GetHashCode(), version2.GetHashCode()); }
/// <summary> /// Creates a new instance of <see cref="EventEnvelope"/> for the specified <paramref name="aggregateId"/>, <paramref name="version"/> and <paramref name="e"/>. /// </summary> /// <param name="correlationId"> The message correlation identifier that is assocaited with this <see cref="EventEnvelope"/>.</param> /// <param name="aggregateId">The unique <see cref="Aggregate"/> identifier that is the source of the associated <see cref="Event"/>.</param> /// <param name="version"> The aggregate version and associated event index that is the source of the associated <see cref="Event"/>.</param> /// <param name="e">The event payload that originated from the specified <see cref="Aggregate"/>.</param> public EventEnvelope(Guid correlationId, Guid aggregateId, EventVersion version, Event e) { Verify.NotNull(e, nameof(e)); this.correlationId = correlationId; this.aggregateId = aggregateId; this.version = version; this.e = e; }
public void CanSerializeToBson() { var version = new EventVersion(3, 2, 1); var aggregateId = Guid.Parse("512fe943-c9bd-49c3-8116-20c186c755af"); var correlationId = Guid.Parse("4fabd791-ef41-4d6b-9579-fcd9189d492b"); var envelope = new EventEnvelope(correlationId, aggregateId, version, new FakeEvent("My Event")); var bson = WriteBson(envelope); Validate(bson, "7AAAAAVhABAAAAAEQ+kvUb3Jw0mBFiDBhsdVrwN2ABoAAAAQdgADAAAAEGMAAgAAABBpAAEAAAAAA2UAlwAAAAIkdHlwZQBwAAAAVGVzdC5TcGFyay5TZXJpYWxpemF0aW9uLkNvbnZlcnRlcnMuVXNpbmdFdmVudEVudmVsb3BlQ29udmVydGVyLkZha2VFdmVudCwgU3BhcmsuU2VyaWFsaXphdGlvbi5OZXd0b25zb2Z0LlRlc3RzAAJQcm9wZXJ0eQAJAAAATXkgRXZlbnQAAAVjABAAAAAEkderT0Hva02VefzZGJ1JKwA="); }
public RestEvent(EventType Ty, EventVersion V, string M, string T, string O, string Ta) { Type = Ty; Version = V; Message = System.Web.HttpUtility.HtmlEncode(M); Title = T; Origin = System.Web.HttpUtility.HtmlEncode(O); Target = System.Web.HttpUtility.HtmlEncode(Ta); ID = Math.Abs(DateTime.Now.GetHashCode()); }
/// <summary> /// Publish any pending saga timeouts. /// </summary> /// <param name="sagaTimeouts">The set of saga timeouts to dispatch.</param> private void DispatchSagaTimeouts(IEnumerable <SagaTimeout> sagaTimeouts) { Log.Trace("Dispatching saga timeouts"); var eventPublisher = lazyEventPublisher.Value; foreach (var sagaTimeout in sagaTimeouts) { var eventVersion = new EventVersion(Int32.MaxValue, 1, 1); var e = new Timeout(sagaTimeout.SagaType, sagaTimeout.Timeout); eventPublisher.Publish(HeaderCollection.Empty, new EventEnvelope(GuidStrategy.NewGuid(), sagaTimeout.SagaId, eventVersion, e)); } Log.Trace("Saga timeouts dispatched"); }
public static DynamicTableEntity ToEntity( this EventVersion version, string aggregateId, long commitId) { Ensure.ArgumentNotNull(version, nameof(version)); Ensure.ArgumentNotNullOrWhiteSpace(aggregateId, nameof(aggregateId)); var dte = new DynamicTableEntity(aggregateId, StorageConstants.EventStore.VersionRowValue); dte.Properties = new Dictionary <string, EntityProperty>(); dte.Properties.Add(StorageConstants.EventStore.VersionColumn, EntityProperty.GeneratePropertyForLong(version.Version)); dte.Properties.Add(StorageConstants.EventStore.LatestCommitID, EntityProperty.GeneratePropertyForLong(commitId)); // Most important thing here dte.ETag = version.ETag; return(dte); }
public void CanSerializeToJson() { var version = new EventVersion(3, 2, 1); var aggregateId = Guid.Parse("512fe943-c9bd-49c3-8116-20c186c755af"); var correlationId = Guid.Parse("4fabd791-ef41-4d6b-9579-fcd9189d492b"); var envelope = new EventEnvelope(correlationId, aggregateId, version, new FakeEvent("My Event")); var json = WriteJson(envelope); Validate(json, @" { ""a"": ""512fe943-c9bd-49c3-8116-20c186c755af"", ""v"": { ""v"": 3, ""c"": 2, ""i"": 1 }, ""e"": { ""$type"": ""Test.Spark.Serialization.Converters.UsingEventEnvelopeConverter.FakeEvent, Spark.Serialization.Newtonsoft.Tests"", ""Property"": ""My Event"" }, ""c"": ""4fabd791-ef41-4d6b-9579-fcd9189d492b"" }"); }
public override int GetHashCode() { return(string.Format("{0}_{1}_{2}_{3}", EventName.GetHashCode(), EventVersion.GetHashCode(), Notes.GetHashCode(), Filter.GetHashCode()).GetHashCode()); }
/// <summary> /// Publish any pending saga timeouts. /// </summary> /// <param name="sagaTimeouts">The set of saga timeouts to dispatch.</param> private void DispatchSagaTimeouts(IEnumerable<SagaTimeout> sagaTimeouts) { Log.Trace("Dispatching saga timeouts"); var eventPublisher = lazyEventPublisher.Value; foreach (var sagaTimeout in sagaTimeouts) { var eventVersion = new EventVersion(Int32.MaxValue, 1, 1); var e = new Timeout(sagaTimeout.SagaType, sagaTimeout.Timeout); eventPublisher.Publish(HeaderCollection.Empty, new EventEnvelope(GuidStrategy.NewGuid(), sagaTimeout.SagaId, eventVersion, e)); } Log.Trace("Saga timeouts dispatched"); }
/// <summary> /// Dispatch all events within the specified <paramref name="commit"/>. /// </summary> /// <param name="commit">The commit instance to be dispatched.</param> private void DispatchCommit(Commit commit) { var commitId = commit.Id.GetValueOrDefault(); var events = commit.Events; for (var i = 0; i < events.Count; i++) { var e = events[i]; var version = new EventVersion(commit.Version, events.Count, i + 1); eventPublisher.Publish(commit.Headers, new EventEnvelope(commit.CorrelationId, commit.StreamId, version, e)); } if (markDispatched) eventStore.MarkDispatched(commitId); }
public void ReturnFriendlyDescription() { var version = new EventVersion(1, 1, 1); Assert.Equal("1 (Event 1 of 1)", version.ToString()); }
public virtual async Task CreateAsync() { this._currentVersion = await this._stream.GetCurrentVersionAsync(this._aggregateId); }