diff --git a/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj b/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
index 06b75df3b..065ce3bb2 100644
--- a/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
+++ b/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
@@ -13,6 +13,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
all
diff --git a/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/AppendingEvents.cs b/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/AppendingEvents.cs
index 9114c1e69..92c3881e4 100644
--- a/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/AppendingEvents.cs
+++ b/Workshops/IntroductionToEventSourcing/03-AppendingEvents.Marten/AppendingEvents.cs
@@ -79,8 +79,12 @@ public async Task AppendingEvents_ForSequenceOfEvents_ShouldSucceed()
new ShoppingCartCanceled(shoppingCartId, DateTime.UtcNow)
};
- const string connectionString =
- "PORT = 5432; HOST = localhost; TIMEOUT = 15; POOLING = True; DATABASE = 'postgres'; PASSWORD = 'Password12!'; USER ID = 'postgres'";
+ await using var server = new MysticMind.PostgresEmbed.PgServer("15.3.0");
+
+ await server.StartAsync();
+ // using Npgsql to connect the server
+ var connectionString =
+ $"Server=localhost;Port={server.PgPort};User Id=postgres;Password=test;Database=postgres";
using var documentStore = DocumentStore.For(options =>
{
diff --git a/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/05-GettingStateFromEvents.Marten.csproj b/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/05-GettingStateFromEvents.Marten.csproj
index fc4486ab0..c310c4a05 100644
--- a/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/05-GettingStateFromEvents.Marten.csproj
+++ b/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/05-GettingStateFromEvents.Marten.csproj
@@ -13,6 +13,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
all
diff --git a/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/Tools/MartenTest.cs b/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/Tools/MartenTest.cs
index 8117ce379..1eef194fa 100644
--- a/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/Tools/MartenTest.cs
+++ b/Workshops/IntroductionToEventSourcing/05-GettingStateFromEvents.Marten/Tools/MartenTest.cs
@@ -1,4 +1,5 @@
using Marten;
+using MysticMind.PostgresEmbed;
namespace IntroductionToEventSourcing.GettingStateFromEvents.Tools;
@@ -6,12 +7,20 @@ public abstract class MartenTest: IDisposable
{
private readonly DocumentStore documentStore;
protected readonly IDocumentSession DocumentSession;
+ protected readonly PgServer PgServer;
protected MartenTest()
{
+ PgServer = new PgServer("15.3.0");
+
+ PgServer.Start();
+ // using Npgsql to connect the server
+ var connectionString =
+ $"Server=localhost;Port={PgServer.PgPort};User Id=postgres;Password=test;Database=postgres";
+
+
var options = new StoreOptions();
- options.Connection(
- "PORT = 5432; HOST = localhost; TIMEOUT = 15; POOLING = True; DATABASE = 'postgres'; PASSWORD = 'Password12!'; USER ID = 'postgres'");
+ options.Connection(connectionString);
options.UseNewtonsoftForSerialization(nonPublicMembersStorage: NonPublicMembersStorage.All);
options.DatabaseSchemaName = options.Events.DatabaseSchemaName = "IntroductionToEventSourcing";
@@ -32,5 +41,6 @@ public virtual void Dispose()
{
DocumentSession.Dispose();
documentStore.Dispose();
+ PgServer.Dispose();
}
}
diff --git a/Workshops/IntroductionToEventSourcing/08-ApplicationLogic.Marten/08-ApplicationLogic.Marten.csproj b/Workshops/IntroductionToEventSourcing/08-ApplicationLogic.Marten/08-ApplicationLogic.Marten.csproj
index b26244ff6..d6fc0c5e6 100644
--- a/Workshops/IntroductionToEventSourcing/08-ApplicationLogic.Marten/08-ApplicationLogic.Marten.csproj
+++ b/Workshops/IntroductionToEventSourcing/08-ApplicationLogic.Marten/08-ApplicationLogic.Marten.csproj
@@ -10,6 +10,7 @@
+
diff --git a/Workshops/IntroductionToEventSourcing/10-OptimisticConcurrency.Marten/10-OptimisticConcurrency.Marten.csproj b/Workshops/IntroductionToEventSourcing/10-OptimisticConcurrency.Marten/10-OptimisticConcurrency.Marten.csproj
index 0dd4b37df..aba3bf052 100644
--- a/Workshops/IntroductionToEventSourcing/10-OptimisticConcurrency.Marten/10-OptimisticConcurrency.Marten.csproj
+++ b/Workshops/IntroductionToEventSourcing/10-OptimisticConcurrency.Marten/10-OptimisticConcurrency.Marten.csproj
@@ -10,6 +10,7 @@
+
diff --git a/Workshops/IntroductionToEventSourcing/Solved/02-GettingStateFromEvents/02-GettingStateFromEvents.csproj b/Workshops/IntroductionToEventSourcing/Solved/02-GettingStateFromEvents/02-GettingStateFromEvents.csproj
index 39c748a00..d926fac39 100644
--- a/Workshops/IntroductionToEventSourcing/Solved/02-GettingStateFromEvents/02-GettingStateFromEvents.csproj
+++ b/Workshops/IntroductionToEventSourcing/Solved/02-GettingStateFromEvents/02-GettingStateFromEvents.csproj
@@ -13,6 +13,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
all
diff --git a/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj b/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
index 24406ff70..662b0210a 100644
--- a/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
+++ b/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/03-AppendingEvents.Marten.csproj
@@ -13,6 +13,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
all
diff --git a/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/AppendingEvents.cs b/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/AppendingEvents.cs
index 94011c798..497c4d96e 100644
--- a/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/AppendingEvents.cs
+++ b/Workshops/IntroductionToEventSourcing/Solved/03-AppendingEvents.Marten/AppendingEvents.cs
@@ -4,6 +4,7 @@
using Xunit;
namespace IntroductionToEventSourcing.AppendingEvents;
+
using static ShoppingCartEvent;
// EVENTS
@@ -35,7 +36,7 @@ DateTime CanceledAt
): ShoppingCartEvent;
// This won't allow external inheritance
- private ShoppingCartEvent(){}
+ private ShoppingCartEvent() { }
}
// VALUE OBJECTS
@@ -88,10 +89,13 @@ public async Task AppendingEvents_ForSequenceOfEvents_ShouldSucceed()
new ShoppingCartCanceled(shoppingCartId, DateTime.UtcNow)
};
- const string connectionString =
- "PORT = 5432; HOST = localhost; TIMEOUT = 15; POOLING = True; DATABASE = 'postgres'; PASSWORD = 'Password12!'; USER ID = 'postgres'";
+ await using var server = new MysticMind.PostgresEmbed.PgServer("15.3.0");
+
+ await server.StartAsync();
+ // using Npgsql to connect the server
+ var connectionString = $"Server=localhost;Port={server.PgPort};User Id=postgres;Password=test;Database=postgres";
- using var documentStore = DocumentStore.For(options =>
+ await using var documentStore = DocumentStore.For(options =>
{
options.Connection(connectionString);
options.DatabaseSchemaName = options.Events.DatabaseSchemaName = "IntroductionToEventSourcing";