-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for strong typed identifier usage w/ CustomProjection
- Loading branch information
1 parent
769e03d
commit 63eaa10
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using EventSourcingTests.Aggregation; | ||
using Marten.Events; | ||
using Shouldly; | ||
using StronglyTypedIds; | ||
using Xunit; | ||
|
||
namespace EventSourcingTests.Projections; | ||
|
||
public class identity_from_event | ||
{ | ||
[Fact] | ||
public void by_string() | ||
{ | ||
var e = new Event<AEvent>(new AEvent()) { StreamKey = "foo" }; | ||
|
||
e.IdentityFromEvent<string>(StreamIdentity.AsString) | ||
.ShouldBe("foo"); | ||
} | ||
|
||
[Fact] | ||
public void by_guid() | ||
{ | ||
var streamId = Guid.NewGuid(); | ||
var e = new Event<AEvent>(new AEvent()) { StreamId = streamId }; | ||
|
||
e.IdentityFromEvent<Guid>(StreamIdentity.AsGuid) | ||
.ShouldBe(streamId); | ||
} | ||
|
||
[Fact] | ||
public void by_strong_typed_guid() | ||
{ | ||
var streamId = Guid.NewGuid(); | ||
var e = new Event<AEvent>(new AEvent()) { StreamId = streamId }; | ||
|
||
e.IdentityFromEvent<TripId>(StreamIdentity.AsGuid) | ||
.Value.ShouldBe(streamId); | ||
} | ||
|
||
[Fact] | ||
public void by_strong_typed_string() | ||
{ | ||
var e = new Event<AEvent>(new AEvent()) { StreamKey = "bar" }; | ||
|
||
e.IdentityFromEvent<EventSourcingTests.StringId>(StreamIdentity.AsString) | ||
.Value.ShouldBe("bar"); | ||
} | ||
|
||
|
||
} | ||
|
||
[StronglyTypedId(Template.Guid)] | ||
public partial struct TripId; | ||
|
||
[StronglyTypedId(Template.String)] | ||
public partial struct StringId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters