예제 #1
0
 public AppleAggregate(CreateApple command) : base(command.Id)
 {
     ApplyChange(
         new AppleCreated(command.Color,
                          this,
                          command));
 }
예제 #2
0
        public async Task HandleCreateAppleCommand()
        {
            var command = new CreateApple(Guid.NewGuid(), "Green",
                                          new CommandMeta(Guid.NewGuid(), Guid.NewGuid()));
            await _commandPublisher.SendAsync(command);

            Assert.True(AppleCommandHandlers.IsHandled);
        }
        public async Task <IActionResult> Create([FromBody] CreateApple command)
        {
            var ip = HttpContext.Connection.RemoteIpAddress.ToString();

            command.CommandMeta.UserIp = ip;
            await _commandSender.SendAsync(command);

            return(Ok());
        }
예제 #4
0
        public Apple(CreateApple command) : base(command.Id)
        {
            Id     = Guid.NewGuid();
            Color  = command.Color;
            Weight = command.Weight;

            ApplyChange(
                new AppleCreated(
                    Color, Weight,
                    this,
                    command)
                );
        }
예제 #5
0
        public async Task CreateAggregate()
        {
            var id          = Guid.NewGuid();
            var color       = "Green";
            var createApple = new CreateApple(id, color,
                                              new CommandMeta(Guid.NewGuid(), Guid.NewGuid()));
            var aggregate = new AppleAggregate(createApple);

            var events = aggregate.GetUncommittedEvents();
            await _eventStore.AppendAsync(events);

            Assert.Equal(id, aggregate.Id);
            Assert.Equal(aggregate.Color, color);
            Assert.Single(events);
        }
예제 #6
0
 void Start()
 {
     appleAmount = appleAmount.GetComponent <CreateApple> ();
 }