public Task StoreSnapshotAsync <TSnapshot>(
            ThingyId thingyId,
            int aggregateSequenceNumber,
            TSnapshot snapshot)
            where TSnapshot : ISnapshot
        {
            var snapshotDefinition = SnapshotDefinitionService.GetDefinition(typeof(TSnapshot));
            var snapshotMetadata   = new SnapshotMetadata
            {
                AggregateId             = thingyId.Value,
                AggregateName           = "ThingyAggregate",
                AggregateSequenceNumber = aggregateSequenceNumber,
                SnapshotName            = snapshotDefinition.Name,
                SnapshotVersion         = snapshotDefinition.Version,
            };

            return(SnapshotPersistence.SetSnapshotAsync(
                       typeof(ThingyAggregate),
                       thingyId,
                       new SerializedSnapshot(
                           JsonConvert.SerializeObject(snapshotMetadata),
                           JsonConvert.SerializeObject(snapshot),
                           snapshotMetadata),
                       CancellationToken.None));
        }
Esempio n. 2
0
        public void SetUp()
        {
            var snapshotDefinitionService = new SnapshotDefinitionService(Mock <ILog>());

            snapshotDefinitionService.Load(typeof(ThingySnapshotV1), typeof(ThingySnapshotV2), typeof(ThingySnapshot));
            Inject <ISnapshotDefinitionService>(snapshotDefinitionService);
        }
        public void SetUp()
        {
            var snapshotDefinitionService = new SnapshotDefinitionService(
                Logger <SnapshotDefinitionService>(),
                Mock <ILoadedVersionedTypes>());

            snapshotDefinitionService.Load(typeof(ThingySnapshotV1), typeof(ThingySnapshotV2), typeof(ThingySnapshot));
            Inject <ISnapshotDefinitionService>(snapshotDefinitionService);
        }
Esempio n. 4
0
        public void SetUp()
        {
            _resolverMock = InjectMock <IResolver>();
            _resolverMock
            .Setup(r => r.Resolve(typeof(ISnapshotUpgrader <ThingySnapshotV1, ThingySnapshotV2>)))
            .Returns(() => new ThingySnapshotV1ToV2Upgrader());
            _resolverMock
            .Setup(r => r.Resolve(typeof(ISnapshotUpgrader <ThingySnapshotV2, ThingySnapshot>)))
            .Returns(() => new ThingySnapshotV2ToV3Upgrader());

            var snapshotDefinitionService = new SnapshotDefinitionService(Mock <ILog>());

            snapshotDefinitionService.Load(typeof(ThingySnapshotV1), typeof(ThingySnapshotV2), typeof(ThingySnapshot));
            Inject <ISnapshotDefinitionService>(snapshotDefinitionService);
        }
Esempio n. 5
0
        public void SetUp()
        {
            _serviceProviderMock = InjectMock <IServiceProvider>();
            _serviceProviderMock
            .Setup(r => r.GetService(typeof(ISnapshotUpgrader <ThingySnapshotV1, ThingySnapshotV2>)))
            .Returns(() => new ThingySnapshotV1ToV2Upgrader());
            _serviceProviderMock
            .Setup(r => r.GetService(typeof(ISnapshotUpgrader <ThingySnapshotV2, ThingySnapshot>)))
            .Returns(() => new ThingySnapshotV2ToV3Upgrader());

            var snapshotDefinitionService = new SnapshotDefinitionService(
                Logger <SnapshotDefinitionService>(),
                Mock <ILoadedVersionedTypes>());

            snapshotDefinitionService.Load(typeof(ThingySnapshotV1), typeof(ThingySnapshotV2), typeof(ThingySnapshot));
            Inject <ISnapshotDefinitionService>(snapshotDefinitionService);
        }