Exemple #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);
        }
Exemple #2
0
        public void DeletingInvalidKeysFails()
        {
            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.UpdateKeys(new List <ConfigEnvironmentKey> {
                new ConfigEnvironmentKey("Foo", "Bar", "", "", 0)
            });

            Assert.NotEmpty(item.Keys);

            var result = item.DeleteKeys(new List <string> {
                "Baz"
            });

            Assert.True(result.IsError, "result.IsError");
        }
Exemple #3
0
        public void DeleteKeysChangesValues()
        {
            var item = new ConfigEnvironment(new EnvironmentIdentifier("Foo", "Bar"));

            item.UpdateKeys(new List <ConfigEnvironmentKey> {
                new ConfigEnvironmentKey("Foo", "Bar", "", "", 0)
            });

            Assert.NotEmpty(item.Keys);

            item.DeleteKeys(new List <string> {
                "Foo"
            });

            Assert.Empty(item.Keys);
        }