-
-
Notifications
You must be signed in to change notification settings - Fork 447
/
using_the_schema_objects_Tests.cs
52 lines (44 loc) · 1.48 KB
/
using_the_schema_objects_Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using EventSourcingTests.Projections;
using Marten;
using Marten.Testing.Harness;
using Shouldly;
using Weasel.Core;
using Xunit;
namespace EventSourcingTests;
public class using_the_schema_objects_Tests : OneOffConfigurationsContext
{
[Fact]
public void can_build_schema_with_auto_create_none()
{
var id = Guid.NewGuid();
using (var store1 = DocumentStore.For(opts =>
{
opts.Connection(ConnectionSource.ConnectionString);
opts.DatabaseSchemaName = "samples";
}))
{
using (var session = store1.LightweightSession())
{
session.Events.StartStream<Quest>(id, new QuestStarted { Name = "Destroy the Orb" },
new MonsterSlayed { Name = "Troll" }, new MonsterSlayed { Name = "Dragon" });
session.SaveChanges();
}
}
#region sample_registering-event-types
var store2 = DocumentStore.For(_ =>
{
_.DatabaseSchemaName = "samples";
_.Connection(ConnectionSource.ConnectionString);
_.AutoCreateSchemaObjects = AutoCreate.None;
_.Events.AddEventType(typeof(QuestStarted));
_.Events.AddEventType(typeof(MonsterSlayed));
});
#endregion
using (var session = store2.LightweightSession())
{
session.Events.FetchStream(id).Count.ShouldBe(3);
}
store2.Dispose();
}
}