Esempio n. 1
0
        public virtual async Task RetrieveVersionConstrainedSnapshot()
        {
            var eventStore = new Mock <IEventStore>();

            var nextEventId = 0L;

            eventStore.Setup(es => es.WriteEvents(It.IsAny <IList <DomainEvent> >()))
            .ReturnsAsync(() => nextEventId++);

            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.Create();
            await item.WriteRecordedEvents(eventStore.Object);

            var firstSnapshot = item.CreateSnapshot();

            item.UpdateKeys(new[] { new ConfigEnvironmentKey("Foo", "1", "", "", 1) });
            await item.WriteRecordedEvents(eventStore.Object);

            var secondSnapshot = item.CreateSnapshot();

            item.UpdateKeys(new[] { new ConfigEnvironmentKey("Foo", "2", "", "", 2) });
            await item.WriteRecordedEvents(eventStore.Object);

            var thirdSnapshot = item.CreateSnapshot();

            await Store.SaveSnapshots(new[] { firstSnapshot, secondSnapshot, thirdSnapshot });

            var result = await Store.GetSnapshot(nameof(ConfigEnvironment), item.Identifier.ToString(), 1);

            Assert.False(result.IsError, "result.IsError");
            Assert.Equal(secondSnapshot, result.Data);
        }
Esempio n. 2
0
        public void CreateValidSnapshot()
        {
            var item     = new ConfigEnvironment(new EnvironmentIdentifier("FooBar", "Bar"));
            var snapshot = item.CreateSnapshot();

            Assert.Equal(item.CurrentVersion, snapshot.Version);
            Assert.Equal(item.MetaVersion, snapshot.MetaVersion);
            Assert.False(string.IsNullOrWhiteSpace(snapshot.Identifier));
            Assert.False(string.IsNullOrWhiteSpace(snapshot.JsonData));
            Assert.False(string.IsNullOrWhiteSpace(snapshot.DataType));
        }
Esempio n. 3
0
        public virtual async Task StoreDomainObjectSnapshot()
        {
            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.Create();
            item.ImportKeys(new List <ConfigEnvironmentKey> {
                new ConfigEnvironmentKey("Jar", "Jar", "", "", 4711)
            });

            var snapshot = item.CreateSnapshot();

            var result = await Store.SaveSnapshots(new[] { snapshot });

            Assert.False(result.IsError, "result.IsError");
        }
Esempio n. 4
0
        public virtual async Task RetrieveDomainObjectSnapshot()
        {
            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.Create();
            item.ImportKeys(new List <ConfigEnvironmentKey> {
                new ConfigEnvironmentKey("Jar", "Jar", "", "", 4711)
            });

            var snapshot = item.CreateSnapshot();

            await Store.SaveSnapshots(new[] { snapshot });

            var result = await Store.GetSnapshot <ConfigEnvironment>(new EnvironmentIdentifier("Foo", "Bar").ToString());

            Assert.False(result.IsError, "result.IsError");
            Assert.NotNull(result.Data);
            Assert.Equal(snapshot, result.Data);
        }
Esempio n. 5
0
        public virtual async Task GetLatestSnapshotNumbers()
        {
            var esMock = new Mock <IEventStore>(MockBehavior.Strict);

            esMock.Setup(es => es.WriteEvents(It.IsAny <IList <DomainEvent> >()))
            .ReturnsAsync(1)
            .Verifiable("Events not written to EventStore");

            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.Create();
            await item.WriteRecordedEvents(esMock.Object);

            var snapshot = item.CreateSnapshot();

            await Store.SaveSnapshots(new[] { snapshot });

            var result = await Store.GetLatestSnapshotNumbers();

            Assert.False(result.IsError, "result.IsError");
            Assert.Equal(1, result.Data);
        }
Esempio n. 6
0
        public void CreateSnapshot()
        {
            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            Assert.NotNull(item.CreateSnapshot());
        }