Exemplo n.º 1
0
        protected override Task <CommandResult <Guid> > ExecuteCommand(UpdateEntityCommand command, CancellationToken cancellationToken)
        {
            var agg = _aggregateFactory.Create(
                EventStream <EntityTestId> .From(EntityTestId.Empty(),
                                                 new AggregationName(),
                                                 VersionId.Empty(), new ImmutableArray <IDomainEvent>())
                );
            var isSucceed = agg.IsValid;
            var okId      = Guid.Empty;


            if (isSucceed)
            {
                agg.UpdateName(EntityTestId.From(command.AggregateId), Name.From(command.Name));

                isSucceed = agg.IsValid;

                agg.GetEvents().ToImmutableList()
                .ForEach(ev => Publisher.Publish(ev));

                okId = agg.GetChange().AggregationId.Value;
            }

            return(Task.FromResult(new CommandResult <Guid>(isSucceed, okId, agg.Failures)));
        }
Exemplo n.º 2
0
        protected override Task <CommandResult <Guid> > ExecuteCommand(UpdateEntityCommand command, CancellationToken cancellationToken)
        {
            // FIXME: remove this after clear my mind, i do need port the persistence event sourcing infrastructure now :)
            var aggOld = EventStreamBusinessEntityAggregateRoot.Create(EntityTestId.GetNext(),
                                                                       Name.From("My name"), Email.From("*****@*****.**"));

            var currentstream = aggOld.GetChange();
            var agg           = EventStreamBusinessEntityAggregateRoot.ReconstructFrom(currentstream);

            var isSucceed = agg.ValidationResults.IsValid;
            var okId      = Guid.Empty;


            if (isSucceed)
            {
                agg.UpdateName(EntityTestId.From(command.AggregateId), Name.From(command.Name));

                isSucceed = agg.ValidationResults.IsValid;

                agg.GetEvents().ToImmutableList()
                .ForEach(ev => Publisher.Publish(ev));

                okId = agg.GetChange().AggregationId.Value;
            }

            return(Task.FromResult(new CommandResult <Guid>(isSucceed, okId, agg.ValidationResults.Errors.ToImmutableList())));
        }
Exemplo n.º 3
0
        public void EntityId_create_a_valid()
        {
            var fixture = new Fixture();

            fixture.Register <EntityTestId>(() => EntityTestId.From(fixture.Create <Guid>()));

            var entityId = fixture.Create <EntityTestId>();

            Assert.True(entityId.ValidationResults.IsValid);
        }
Exemplo n.º 4
0
        public void EntityId_create_an_invalid()
        {
            var fixture = new Fixture();

            fixture.Register <EntityTestId>(() => EntityTestId.From(Guid.Empty));

            var entityId = fixture.Create <EntityTestId>();

            Assert.True(entityId.ValidationStatus.IsValid);
        }
Exemplo n.º 5
0
 public void EntityTestIdCreateFrom()
 {
     var entity = EntityTestId.From(_id);
 }