Skip to content

Commit

Permalink
Removed the union types in events to simplify the narrative
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Nov 6, 2024
1 parent 96e3e39 commit 8e693b5
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 249 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Text.Json;
using FluentAssertions;
using HotelManagement.GuestStayAccounts;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.Downcasters;

using V1 = GuestStayAccountEvent;

public class ChangedStructure
{
public record Money(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using FluentAssertions;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.SimpleMappings;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using FluentAssertions;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.SimpleMappings;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using FluentAssertions;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.SimpleMappings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class PackageSnapshotTests
[Fact(Skip = "not now, my friend")]
public Task my_assembly_has_no_public_api_changes()
{
var publicApi = typeof(GuestStayAccountEvent).Assembly.GeneratePublicApi();
var publicApi = typeof(GuestCheckedIn).Assembly.GeneratePublicApi();

return Verify(publicApi);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json;
using FluentAssertions;
using HotelManagement.EventStore;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

public record Money(
decimal Amount,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using FluentAssertions;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.Upcasters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using FluentAssertions;
using V1 = HotelManagement.GuestStayAccounts.GuestStayAccountEvent;
using V1 = HotelManagement.GuestStayAccounts;

namespace HotelManagement.Tests.Upcasters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
namespace HotelManagement.GuestStayAccounts;

using static GuestStayAccountEvent;
using static GuestStayAccountCommand;
public record CheckIn(
string ClerkId,
string GuestStayId,
string RoomId,
DateTimeOffset Now
);

public abstract record GuestStayAccountCommand
{
public record CheckIn(
string ClerkId,
string GuestStayId,
string RoomId,
DateTimeOffset Now
): GuestStayAccountCommand;

public record RecordCharge(
string GuestStayAccountId,
decimal Amount,
DateTimeOffset Now
): GuestStayAccountCommand;
public record RecordCharge(
string GuestStayAccountId,
decimal Amount,
DateTimeOffset Now
);

public record RecordPayment(
string GuestStayAccountId,
decimal Amount,
DateTimeOffset Now
): GuestStayAccountCommand;
public record RecordPayment(
string GuestStayAccountId,
decimal Amount,
DateTimeOffset Now
);

public record CheckOut(
string ClerkId,
string GuestStayAccountId,
DateTimeOffset Now
): GuestStayAccountCommand;

private GuestStayAccountCommand() { }
}
public record CheckOut(
string ClerkId,
string GuestStayAccountId,
DateTimeOffset Now
);

public static class GuestStayAccountDecider
{
Expand Down Expand Up @@ -60,7 +52,7 @@ public static PaymentRecorded RecordPayment(RecordPayment command, GuestStayAcco
return new PaymentRecorded(state.Id, command.Amount, command.Now);
}

public static GuestStayAccountEvent CheckOut(CheckOut command, GuestStayAccount state)
public static object CheckOut(CheckOut command, GuestStayAccount state)
{
if (state.Status != GuestStayAccountStatus.Opened)
return new GuestCheckoutFailed(
Expand Down
Loading

0 comments on commit 8e693b5

Please sign in to comment.