Esempio n. 1
0
        public WorkTime?FindFromSnapshot(WorkTimeSnapshotCreated snapshotEvent)
        {
            var found = _repository.FindFromSnapshot(snapshotEvent);

            if (found == null)
            {
                return(null);
            }
            if (found.AggregateId == _moduleService.CurrentWorkTime?.AggregateId)
            {
                return(WorkTime.Combine(found, _moduleService.CurrentWorkTime));
            }

            return(found);
        }
Esempio n. 2
0
        public void FindFromSnapshot_returns_aggregate_from_snapshot()
        {
            var workTime = WorkTimeTestUtils.CreateManual();

            workTime.StartManually();
            var snap = workTime.TakeSnapshot();

            _repository.Save(workTime);
            workTime.MarkPendingEventsAsHandled();

            workTime.AddMouseAction(new MouseKeyboardEvent());

            var fromSnap = _repository.FindFromSnapshot(snap);

            CompareWorkTimes(fromSnap, workTime);
            fromSnap.FromSnapshot.Should().BeTrue();
            fromSnap.MouseActionEvents.Should().BeEmpty();
            fromSnap.KeyboardActionEvents.Should().BeEmpty();
            fromSnap.PendingEvents.Should().BeEmpty();
            fromSnap.AggregateVersion.Should().Be(workTime.AggregateVersion - 1);
        }