Skip to content

Commit

Permalink
Adjusted snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Nov 6, 2024
1 parent 8e693b5 commit c8220cd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
ShoppingCartId: Guid_1,
ClientId: anonymised,
ConfirmedAt: DateTimeOffset_1
GuestStayAccountId: Guid_1,
Amount: 292.333,
RecordedAt: DateTimeOffset_1,
ClerkId: anonymised
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
ShoppingCartId: Guid_1,
ConfirmedAt: DateTimeOffset_1
GuestStayAccountId: Guid_1,
Amount: 292.333,
RecordedAt: DateTimeOffset_1
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@ namespace EventsVersioning.Tests.SnapshotTesting;

public class EventsSnapshotTests
{
private record ShoppingCartConfirmed(
Guid ShoppingCartId,
string? ClientId,
DateTimeOffset ConfirmedAt
public record PaymentRecorded(
string GuestStayAccountId,
decimal Amount,
DateTimeOffset RecordedAt,
string? ClerkId = null
);

[Fact]
public Task ShoppingCartConfirmed_WithCompleteData_IsCompatible()
{
var @event = new ShoppingCartConfirmed(Guid.NewGuid(), "Oskar Dudycz", DateTimeOffset.UtcNow);
var @event = new PaymentRecorded(
Guid.NewGuid().ToString(),
292.333m,
DateTimeOffset.UtcNow,
"Oskar Dudycz"
);
return Verify(@event);
}

[Fact]
public Task ShoppingCartConfirmed_WithOnlyRequiredData_IsCompatible()
{
var @event = new ShoppingCartConfirmed(Guid.NewGuid(), null, DateTimeOffset.UtcNow);
var @event = new PaymentRecorded(
Guid.NewGuid().ToString(),
292.333m,
DateTimeOffset.UtcNow
);
return Verify(@event);
}
}

// note this is optional, if you really need to
// This is just showing that you can
public static class StaticSettingsUsage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace EventsVersioning.Tests.SnapshotTesting;

public class PackageSnapshotTests
{
[Fact(Skip = "not now, my friend")]
[Fact]
public Task my_assembly_has_no_public_api_changes()
{
var publicApi = typeof(GuestCheckedIn).Assembly.GeneratePublicApi();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
using HotelManagement.EventStore;
using V1 = HotelManagement.GuestStayAccounts;

public record Money(
decimal Amount,
string Currency
);

namespace V2
namespace HotelManagement.Tests.Transformations
{
public record Money(
decimal Amount,
string Currency
);

namespace V2
{
public record PaymentRecorded(
string GuestStayAccountId,
Money Amount,
DateTimeOffset RecordedAt
);
}

public record PaymentRecorded(
string GuestStayAccountId,
Money Amount,
DateTimeOffset RecordedAt
DateTimeOffset RecordedAt,
string ClerkId
);
}

public record PaymentRecorded(
string GuestStayAccountId,
Money Amount,
DateTimeOffset RecordedAt,
string ClerkId
);

namespace HotelManagement.Tests.Transformations
{
public class MultipleTransformationsWithDifferentEventTypes
{
public static PaymentRecorded UpcastV1(
Expand Down

0 comments on commit c8220cd

Please sign in to comment.