예제 #1
0
            public void AddAttachesToUnitOfWork()
            {
                var root = AggregateRootEntityStub.Factory();

                _sut.Add(_model.KnownIdentifier, root);

                Aggregate aggregate;
                var       result = _sut.UnitOfWork.TryGet(_model.KnownIdentifier, out aggregate);

                Assert.That(result, Is.True);
                Assert.That(aggregate.Identifier, Is.EqualTo(_model.KnownIdentifier));
                Assert.That(aggregate.Root, Is.SameAs(root));
            }
예제 #2
0
        public async Task HandleAsync(CreateExportDefinition command)
        {
            var exportDefinition = ExportDefinition.CreateNew(command.ExportDefinitionId, command.Name);

            _repository.Add($@"ed-{exportDefinition.ExportDefinitionId}", exportDefinition);

            foreach (var aggregate in _repository.UnitOfWork.GetChanges())
            {
                var aggregateIdentifier      = aggregate.Identifier;
                var aggregateExpectedVersion = aggregate.ExpectedVersion;
                var changes = aggregate.Root.GetChanges().ToArray();

                _repository.AppendToStream(
                    aggregateIdentifier,
                    aggregateExpectedVersion,
                    changes);
            }
        }