Skip to content

Commit

Permalink
Removed obsolete SharpTestEx package and aligned usage to FluentAsser…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
oskardudycz committed Mar 5, 2022
1 parent a28a3e6 commit 9cef9cb
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
<PackageReference Include="Marten" Version="5.0.0-alpha.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MediatR" Version="10.0.1" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="SharpTestsEx" Version="2.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
24 changes: 12 additions & 12 deletions Marten.Integration.Tests/EventStore/Aggregate/EventsAggregation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Aggregate;
Expand Down Expand Up @@ -63,19 +63,19 @@ public void GivenStreamOfEvents_WhenAggregateStreamIsCalled_ThenChangesAreApplie

var issuesList = EventStore.AggregateStream<IssuesList>(streamId)!;

issuesList.Issues.Should().Have.Count.EqualTo(1);
issuesList.Issues.Values.Single().IssueId.Should().Be.EqualTo(issue1Id);
issuesList.Issues.Values.Single().Description.Should().Be.EqualTo("Description");
issuesList.Issues.Should().HaveCount(1);
issuesList.Issues.Values.Single().IssueId.Should().Be(issue1Id);
issuesList.Issues.Values.Single().Description.Should().Be("Description");

//2. First Issue Description Was Changed
EventStore.Append(streamId, new IssueUpdated(issue1Id, "New Description"));
Session.SaveChanges();

issuesList = EventStore.AggregateStream<IssuesList>(streamId)!;

issuesList.Issues.Should().Have.Count.EqualTo(1);
issuesList.Issues.Values.Single().IssueId.Should().Be.EqualTo(issue1Id);
issuesList.Issues.Values.Single().Description.Should().Be.EqualTo("New Description");
issuesList.Issues.Should().HaveCount(1);
issuesList.Issues.Values.Single().IssueId.Should().Be(issue1Id);
issuesList.Issues.Values.Single().Description.Should().Be("New Description");

//3. Two Other tasks were added
EventStore.Append(streamId, new IssueCreated(Guid.NewGuid(), "Description2"),
Expand All @@ -84,20 +84,20 @@ public void GivenStreamOfEvents_WhenAggregateStreamIsCalled_ThenChangesAreApplie

issuesList = EventStore.AggregateStream<IssuesList>(streamId)!;

issuesList.Issues.Should().Have.Count.EqualTo(3);
issuesList.Issues.Should().HaveCount(3);
issuesList.Issues.Values.Select(t => t.Description)
.Should()
.Have.SameSequenceAs("New Description", "Description2", "Description3");
.BeEquivalentTo("New Description", "Description2", "Description3");

//4. First issue was removed
EventStore.Append(streamId, new IssueRemoved(issue1Id));
Session.SaveChanges();

issuesList = EventStore.AggregateStream<IssuesList>(streamId)!;

issuesList.Issues.Should().Have.Count.EqualTo(2);
issuesList.Issues.Should().HaveCount(2);
issuesList.Issues.Values.Select(t => t.Description)
.Should()
.Have.SameSequenceAs("Description2", "Description3");
.BeEquivalentTo("Description2", "Description3");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Aggregate;
Expand Down Expand Up @@ -74,10 +74,10 @@ public void GivenEvents_WhenInlineTransformationIsApplied_ThenReturnsSameNumberO
//3. Get inline aggregation
var issuesListFromInlineAggregation = Session.Load<IssuesList>(streamId)!;

issuesListFromLiveAggregation.Should().Not.Be.Null();
issuesListFromInlineAggregation.Should().Not.Be.Null();
issuesListFromLiveAggregation.Should().NotBeNull();
issuesListFromInlineAggregation.Should().NotBeNull();

issuesListFromLiveAggregation.Issues.Count.Should().Be.EqualTo(2);
issuesListFromLiveAggregation.Issues.Count.Should().Be.EqualTo(issuesListFromInlineAggregation.Issues.Count);
issuesListFromLiveAggregation.Issues.Count.Should().Be(2);
issuesListFromLiveAggregation.Issues.Count.Should().Be(issuesListFromInlineAggregation.Issues.Count);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Weasel.Core;
using Xunit;

Expand Down Expand Up @@ -87,10 +87,10 @@ public void GivenOutOfOrderEvents_WhenPublishedWithSetVersion_ThenLiveAggregatio
//3. Get inline aggregation
var issuesListFromInlineAggregation = Session.Load<IssuesList>(streamId);

issuesListFromLiveAggregation.Should().Not.Be.Null();
issuesListFromInlineAggregation.Should().Not.Be.Null();
issuesListFromLiveAggregation.Should().NotBeNull();
issuesListFromInlineAggregation.Should().NotBeNull();

issuesListFromLiveAggregation!.Issues.Count.Should().Be.EqualTo(2);
issuesListFromLiveAggregation!.Issues.Count.Should().Be.EqualTo(issuesListFromInlineAggregation!.Issues.Count);
issuesListFromLiveAggregation!.Issues.Count.Should().Be(2);
issuesListFromLiveAggregation!.Issues.Count.Should().Be(issuesListFromInlineAggregation!.Issues.Count);
}
}
22 changes: 11 additions & 11 deletions Marten.Integration.Tests/EventStore/Aggregate/Reaggregation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Aggregate
Expand Down Expand Up @@ -98,8 +98,8 @@ public void Given_When_Then()
}

//2. Both inline and online aggregation for the same type should be the same
issueFromV1InlineAggregation.Description.Should().Be.EqualTo("Issue 1 Updated");
issueFromV1InlineAggregation.Description.Should().Be.EqualTo(issueFromV1OnlineAggregation.Description);
issueFromV1InlineAggregation.Description.Should().Be("Issue 1 Updated");
issueFromV1InlineAggregation.Description.Should().Be(issueFromV1OnlineAggregation.Description);

//3. Simulate change to aggregation logic
NewVersion.Issue issueFromV2InlineAggregation;
Expand All @@ -112,12 +112,12 @@ public void Given_When_Then()
}

//4. Inline aggregated snapshot won't change automatically
issueFromV2InlineAggregation.Description.Should().Be.EqualTo(issueFromV1InlineAggregation.Description);
issueFromV2InlineAggregation.Description.Should().Not.Be.EqualTo("New Logic: Issue 1 Updated");
issueFromV2InlineAggregation.Description.Should().Be(issueFromV1InlineAggregation.Description);
issueFromV2InlineAggregation.Description.Should().NotBe("New Logic: Issue 1 Updated");

//5. But online aggregation is being applied automatically
issueFromV2OnlineAggregation.Description.Should().Not.Be.EqualTo(issueFromV1OnlineAggregation.Description);
issueFromV2OnlineAggregation.Description.Should().Be.EqualTo("New Logic: Issue 1 Updated");
issueFromV2OnlineAggregation.Description.Should().NotBe(issueFromV1OnlineAggregation.Description);
issueFromV2OnlineAggregation.Description.Should().Be("New Logic: Issue 1 Updated");

//6. Reagregation
using (var session = CreateSessionWithInlineAggregationFor<NewVersion.Issue>())
Expand All @@ -129,9 +129,9 @@ public void Given_When_Then()

var taskFromV2AfterReaggregation = session.Load<NewVersion.Issue>(taskId)!;

taskFromV2AfterReaggregation.Description.Should().Not.Be.EqualTo(issueFromV1OnlineAggregation.Description);
taskFromV2AfterReaggregation.Description.Should().Be.EqualTo(issueFromV2OnlineAggregation.Description);
taskFromV2AfterReaggregation.Description.Should().Be.EqualTo("New Logic: Issue 1 Updated");
taskFromV2AfterReaggregation.Description.Should().NotBe(issueFromV1OnlineAggregation.Description);
taskFromV2AfterReaggregation.Description.Should().Be(issueFromV2OnlineAggregation.Description);
taskFromV2AfterReaggregation.Description.Should().Be("New Logic: Issue 1 Updated");

//9. Check if next event would be properly applied to inline aggregation
session.Events.Append(taskId, new IssueUpdated(taskId, "Completely New text"));
Expand All @@ -141,7 +141,7 @@ public void Given_When_Then()
using (var session = CreateSessionWithInlineAggregationFor<NewVersion.Issue>())
{
var taskFromV2NewInlineAggregation = session.Load<NewVersion.Issue>(taskId)!;
taskFromV2NewInlineAggregation.Description.Should().Be.EqualTo("New Logic: Completely New text");
taskFromV2NewInlineAggregation.Description.Should().Be("New Logic: Completely New text");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using Marten.Events.Aggregation;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Weasel.Core;
using Xunit;

Expand Down Expand Up @@ -115,13 +115,13 @@ public void GivenEvents_WhenInlineTransformationIsApplied_ThenReturnsSameNumberO

var projection = Session.Query<IssueDescriptions>().FirstOrDefault();

issuesListFromLiveAggregation.Should().Not.Be.Null();
issuesListFromInlineAggregation.Should().Not.Be.Null();
projection.Should().Not.Be.Null();
issuesListFromLiveAggregation.Should().NotBeNull();
issuesListFromInlineAggregation.Should().NotBeNull();
projection.Should().NotBeNull();

issuesListFromLiveAggregation!.Issues.Count.Should().Be.EqualTo(2);
issuesListFromInlineAggregation!.Issues.Count.Should().Be.EqualTo(2);
projection!.Descriptions.Count.Should().Be.EqualTo(2);
issuesListFromLiveAggregation!.Issues.Count.Should().Be(2);
issuesListFromInlineAggregation!.Issues.Count.Should().Be(2);
projection!.Descriptions.Count.Should().Be(2);

}
}
16 changes: 8 additions & 8 deletions Marten.Integration.Tests/EventStore/Stream/StreamLoading.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Stream;
Expand Down Expand Up @@ -37,8 +37,8 @@ public void GivenExistingStream_WithOneEventWhenStreamIsLoaded_ThenItLoadsOneEve
var events = EventStore.FetchStream(streamId);

//Then
events.Count.Should().Be.EqualTo(1);
events.First().Version.Should().Be.EqualTo(1);
events.Count.Should().Be(1);
events.First().Version.Should().Be(1);
}

[Fact]
Expand All @@ -54,8 +54,8 @@ public void GivenExistingStreamWithOneEvent_WhenEventIsAppended_ThenItLoadsTwoEv
//Then
var events = EventStore.FetchStream(streamId);

events.Count.Should().Be.EqualTo(2);
events.Last().Version.Should().Be.EqualTo(2);
events.Count.Should().Be(2);
events.Last().Version.Should().Be(2);
}

[Fact]
Expand All @@ -69,7 +69,7 @@ public void GivenExistingStreamWithOneEvent_WhenStreamIsLoadedByEventType_ThenIt
var @event = EventStore.Load<IssueCreated>(eventId);

//Then
@event.Should().Not.Be.Null();
@event.Id.Should().Be.EqualTo(eventId);
@event.Should().NotBeNull();
@event.Id.Should().Be(eventId);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Stream;
Expand Down Expand Up @@ -41,16 +41,16 @@ public void GivenSetOfEvents_WithFetchEventsFromDifferentTimes_ThenProperSetsAre

//Then
var events = EventStore.FetchStream(streamId, timestamp: beforeCreateTimestamp);
events.Count.Should().Be.EqualTo(0);
events.Count.Should().Be(0);

events = EventStore.FetchStream(streamId, timestamp: createTimestamp);
events.Count.Should().Be.EqualTo(1);
events.Count.Should().Be(1);

events = EventStore.FetchStream(streamId, timestamp: firstUpdateTimestamp);
events.Count.Should().Be.EqualTo(2);
events.Count.Should().Be(2);

events = EventStore.FetchStream(streamId, timestamp: secondUpdateTimestamp);
events.Count.Should().Be.EqualTo(4);
events.Count.Should().Be(4);
}

[Fact]
Expand All @@ -74,25 +74,25 @@ public void GivenSetOfEvents_WithFetchEventsFromDifferentVersionNumber_ThenPrope
//Then
//version after create
var events = EventStore.FetchStream(streamId, 1);
events.Count.Should().Be.EqualTo(1);
events.Count.Should().Be(1);

//version after first update
events = EventStore.FetchStream(streamId, 2);
events.Count.Should().Be.EqualTo(2);
events.Count.Should().Be(2);

//even though 3 and 4 updates were append at the same time version is incremented for both of them
events = EventStore.FetchStream(streamId, 3);
events.Count.Should().Be.EqualTo(3);
events.Count.Should().Be(3);

events = EventStore.FetchStream(streamId, 4);
events.Count.Should().Be.EqualTo(4);
events.Count.Should().Be(4);

//fetching with version equal to 0 returns the most recent state
events = EventStore.FetchStream(streamId, 0);
events.Count.Should().Be.EqualTo(4);
events.Count.Should().Be(4);

//providing bigger version than current doesn't throws exception - returns most recent state
events = EventStore.FetchStream(streamId, 100);
events.Count.Should().Be.EqualTo(4);
events.Count.Should().Be(4);
}
}
}
14 changes: 7 additions & 7 deletions Marten.Integration.Tests/EventStore/Stream/StreamStarting.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using Marten.Exceptions;
using Marten.Integration.Tests.TestsInfrastructure;
using SharpTestsEx;
using Xunit;

namespace Marten.Integration.Tests.EventStore.Stream;
Expand Down Expand Up @@ -31,7 +31,7 @@ public void GivenNoEvents_WhenStreamIsStarting_ThenEventsAreSavedWithoutError()

Session.SaveChanges();

streamId.Should().Not.Be.Null();
streamId.Should().NotBeNull();
}

[Fact]
Expand All @@ -41,7 +41,7 @@ public void GivenOneEvent_WhenStreamIsStarting_ThenEventsAreSavedWithoutError()

var streamId = EventStore.StartStream(@event.IssueId, @event);

streamId.Should().Not.Be.Null();
streamId.Should().NotBeNull();

Session.SaveChanges();
}
Expand Down Expand Up @@ -74,8 +74,8 @@ public void GivenOneEvent_WhenEventsArePublishedWithStreamId_ThenEventsAreSavedW

var streamState = EventStore.FetchStreamState(streamId);

streamState.Should().Not.Be.Null();
streamState.Version.Should().Be.EqualTo(1);
streamState.Should().NotBeNull();
streamState.Version.Should().Be(1);
}

[Fact]
Expand All @@ -90,8 +90,8 @@ public void GivenMoreThenOneEvent_WhenStreamIsStarting_ThenEventsAreSavedWithout

var streamId = EventStore.StartStream(events);

streamId.Should().Not.Be.Null();
streamId.Should().NotBeNull();

Session.SaveChanges();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@
// //2. Get transformed events
// var changeLogs = Session.Query<IssueChangesLog>().ToList();
//
// changeLogs.Should().Have.Count.EqualTo(events.Length);
// changeLogs.Should().HaveCount(events.Length);
//
// changeLogs.Select(ev => ev.IssueId)
// .Should().Have.SameValuesAs(events.Select(ev => ev.IssueId));
//
// changeLogs.Count(ev => ev.ChangeType == ChangeType.Creation)
// .Should().Be.EqualTo(events.OfType<IssueCreated>().Count());
// .Should().Be(events.OfType<IssueCreated>().Count());
//
// changeLogs.Count(ev => ev.ChangeType == ChangeType.Modification)
// .Should().Be.EqualTo(events.OfType<IssueUpdated>().Count());
// .Should().Be(events.OfType<IssueUpdated>().Count());
//
// changeLogs.Count(ev => ev.IssueId == issue1Id)
// .Should().Be.EqualTo(events.Count(ev => ev.IssueId == issue1Id));
// .Should().Be(events.Count(ev => ev.IssueId == issue1Id));
//
// changeLogs.Count(ev => ev.IssueId == issue2Id)
// .Should().Be.EqualTo(events.Count(ev => ev.IssueId == issue2Id));
// .Should().Be(events.Count(ev => ev.IssueId == issue2Id));
// }
// }
// }
Loading

0 comments on commit 9cef9cb

Please sign in to comment.