Skip to content

Commit 4e1543d

Browse files
Andreas Gehrkechristianhelle
Andreas Gehrke
authored andcommitted
Add tests of EventStreamId
1 parent dbf44c7 commit 4e1543d

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/Atc.Cosmos.EventStore.Cqrs/EventStreamId.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public EventStreamId(EventStreamId existing)
3131
public string Value { get; }
3232

3333
public static implicit operator EventStreamId(StreamId id)
34-
=> FromStreamId(id.Value);
34+
=> FromStreamId(id);
3535

3636
public static EventStreamId FromStreamId(StreamId id)
3737
=> new(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using FluentAssertions;
2+
using Xunit;
3+
4+
namespace Atc.Cosmos.EventStore.Cqrs.Commands.Tests;
5+
6+
public class EventStreamIdTests
7+
{
8+
[Fact]
9+
public void Ctor_must_throw_when_no_arguments_are_provided()
10+
{
11+
Assert.Throws<ArgumentException>(() => new EventStreamId());
12+
}
13+
14+
[Fact]
15+
public void Value_property_must_return_joined_parts()
16+
{
17+
var id = new EventStreamId("foo", "bar");
18+
id.Value.Should().Be("foo.bar");
19+
}
20+
21+
[Fact]
22+
public void Parts_property_must_return_parts()
23+
{
24+
var id = new EventStreamId("foo", "bar");
25+
id.Parts.Should().BeEquivalentTo("foo", "bar");
26+
}
27+
28+
[Fact]
29+
public void EventStreamId_can_be_cloned_using_ctor()
30+
{
31+
var id = new EventStreamId("foo", "bar");
32+
var clone = new EventStreamId(id);
33+
id.Value.Should().Be(clone.Value);
34+
}
35+
36+
[Fact]
37+
public void EventStreamId_can_be_created_from_StreamId()
38+
{
39+
var streamId = new StreamId("foo.bar");
40+
EventStreamId eventStreamId = streamId;
41+
EventStreamId eventStreamId2 = EventStreamId.FromStreamId(streamId);
42+
eventStreamId.Value.Should().Be("foo.bar");
43+
eventStreamId2.Value.Should().Be("foo.bar");
44+
}
45+
}

0 commit comments

Comments
 (0)