Skip to content

Commit

Permalink
Added tests for multiple events's schemas with SystemTextJson and Js…
Browse files Browse the repository at this point in the history
…onNet raw transformations using classes
  • Loading branch information
oskardudycz committed Sep 2, 2022
1 parent fd71ef7 commit fb387e0
Show file tree
Hide file tree
Showing 4 changed files with 592 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EventSourcingTests.SchemaChange.MultipleVersions.Classes
{
namespace WithTheSameName
namespace Clr.WithTheSameName
{
public class ShoppingCartOpenedV1toV2Upcaster:
EventUpcaster<V1.ShoppingCartOpened, V2.WithTheSameName.ShoppingCartOpened>
Expand Down Expand Up @@ -92,7 +92,7 @@ V2.WithTheSameName.ProductItemAddedToShoppingCart @event
}
}

namespace WithDifferentName
namespace Clr.WithDifferentName
{
public class ShoppingCartOpenedV1toV2Upcaster:
EventUpcaster<V1.ShoppingCartOpened, V2.WithDifferentName.ShoppingCartOpenedV2>
Expand Down Expand Up @@ -146,9 +146,6 @@ V1.ProductItemAddedToShoppingCart @event
public class ShoppingCartOpenedV2toV3Upcaster:
EventUpcaster<V2.WithDifferentName.ShoppingCartOpenedV2, V3.WithDifferentName.ShoppingCartOpenedV3>
{
public override string EventTypeName =>
GetEventTypeNameWithSchemaVersion<V1.ShoppingCartOpened>(2);

protected override V3.WithDifferentName.ShoppingCartOpenedV3 Upcast(
V2.WithDifferentName.ShoppingCartOpenedV2 @event
) =>
Expand All @@ -164,9 +161,6 @@ public class ProductItemAddedToShoppingCartV2toV3Upcaster:
EventUpcaster<V2.WithDifferentName.ProductItemAddedToShoppingCartV2,
V3.WithDifferentName.ProductItemAddedToShoppingCartV3>
{
public override string EventTypeName =>
GetEventTypeNameWithSchemaVersion<V1.ProductItemAddedToShoppingCart>(2);

protected override V3.WithDifferentName.ProductItemAddedToShoppingCartV3 Upcast(
V2.WithDifferentName.ProductItemAddedToShoppingCartV2 @event
) =>
Expand All @@ -177,15 +171,14 @@ V2.WithDifferentName.ProductItemAddedToShoppingCartV2 @event
}
}


public class ClrUpcastConfiguration
{
public static Action<StoreOptions> V2WithTheSameName =>
options => options.Events
.Upcast
(
new WithTheSameName.ShoppingCartOpenedV1toV2Upcaster(),
new WithTheSameName.ProductItemAddedToShoppingCartV1toV2Upcaster()
new Clr.WithTheSameName.ShoppingCartOpenedV1toV2Upcaster(),
new Clr.WithTheSameName.ProductItemAddedToShoppingCartV1toV2Upcaster()
)
.MapEventTypeWithSchemaVersion<
V2.WithTheSameName.ShoppingCartOpened>(2)
Expand All @@ -196,10 +189,10 @@ public class ClrUpcastConfiguration
options => options.Events
.Upcast
(
new WithTheSameName.ShoppingCartOpenedV1toV3Upcaster(),
new WithTheSameName.ProductItemAddedToShoppingCartV1toV3Upcaster(),
new WithTheSameName.ShoppingCartOpenedV2toV3Upcaster(),
new WithTheSameName.ProductItemAddedToShoppingCartV2toV3Upcaster()
new Clr.WithTheSameName.ShoppingCartOpenedV1toV3Upcaster(),
new Clr.WithTheSameName.ProductItemAddedToShoppingCartV1toV3Upcaster(),
new Clr.WithTheSameName.ShoppingCartOpenedV2toV3Upcaster(),
new Clr.WithTheSameName.ProductItemAddedToShoppingCartV2toV3Upcaster()
)
.MapEventTypeWithSchemaVersion<
V3.WithTheSameName.ShoppingCartOpened>(3)
Expand All @@ -210,18 +203,18 @@ public class ClrUpcastConfiguration
options => options.Events
.Upcast
(
new WithDifferentName.ShoppingCartOpenedV1toV2Upcaster(),
new WithDifferentName.ProductItemAddedToShoppingCartV1toV2Upcaster()
new Clr.WithDifferentName.ShoppingCartOpenedV1toV2Upcaster(),
new Clr.WithDifferentName.ProductItemAddedToShoppingCartV1toV2Upcaster()
);

public static Action<StoreOptions> V3WithDifferentName =>
options => options.Events
.Upcast
(
new WithDifferentName.ShoppingCartOpenedV1toV3Upcaster(),
new WithDifferentName.ProductItemAddedToShoppingCartV1toV3Upcaster(),
new WithDifferentName.ShoppingCartOpenedV2toV3Upcaster(),
new WithDifferentName.ProductItemAddedToShoppingCartV2toV3Upcaster()
new Clr.WithDifferentName.ShoppingCartOpenedV1toV3Upcaster(),
new Clr.WithDifferentName.ProductItemAddedToShoppingCartV1toV3Upcaster(),
new Clr.WithDifferentName.ShoppingCartOpenedV2toV3Upcaster(),
new Clr.WithDifferentName.ProductItemAddedToShoppingCartV2toV3Upcaster()
);
}
}
Expand Down
Loading

0 comments on commit fb387e0

Please sign in to comment.