Exemplo n.º 1
0
        public string Cancel(Guid id)
        {
            var aggregate = new MeetupAggregate(id);

            aggregate.Cancel();
            return(aggregate.State.ToString());
        }
Exemplo n.º 2
0
        public static void GivenCreatedMeetup <TException>(Action <MeetupAggregate> when)
            where TException : Exception
        {
            var meetup = new MeetupAggregate(id, title, location);

            Assert.Throws <TException>(() => when(meetup));
        }
Exemplo n.º 3
0
        public string Publish(MeetupPublishCommand command)
        {
            var aggregate = new MeetupAggregate(command.MeetupId);

            aggregate.Publish(command);
            return(aggregate.State.ToString());
        }
Exemplo n.º 4
0
        public static void GivenCreatedMeetup(Action <MeetupAggregate> when, Action <MeetupAggregate> then)
        {
            var meetup = new MeetupAggregate(id, title, location);

            when(meetup);
            then(meetup);
        }
Exemplo n.º 5
0
        private MeetupAggregate ExecuteCommand(Action <MeetupAggregate> command)
        {
            var meetupId = Guid.NewGuid();
            var meetup   = new MeetupAggregate(meetupId);

            command(meetup);
            return(meetup);
        }
Exemplo n.º 6
0
        public void MeetupCreateTest()
        {
            var meetup = new MeetupAggregate(id, title, location);

            Assert.Equal(title, meetup.Title);
            Assert.Equal(location, meetup.Location);
            Assert.Equal(MeetupState.Created, meetup.State);
        }
Exemplo n.º 7
0
 private static MeetupAggregate ExecuteCommand(this MeetupAggregate @this, Func <MeetupAggregate> command)
 {
     @this.UpdateNumberOfSeats(SeatsNumber.From(numberOfSeats));
     @this.UpdateLocation(Address.From(address));
     @this.UpdateTime(timeRange);
     @this = command();
     return(@this);
 }
Exemplo n.º 8
0
        public static void GivenPublishedMeetup(Action <MeetupAggregate> when, Action <MeetupAggregate> then)
        {
            var meetup = new MeetupAggregate(id, title, location);

            meetup.UpdateNumberOfSeats(seats);
            meetup.Publish();
            when(meetup);
            then(meetup);
        }
Exemplo n.º 9
0
        public void Given_Invalid_EvenStream_When_Build_Then_Throws()
        {
            var id = MeetupId.From(Guid.NewGuid());

            Assert.Throws <MeetupDomainException>(() =>
                                                  MeetupAggregate.Build(
                                                      id,
                                                      new Events.MeetupCreated(id, "EventSourcing with Marten"),
                                                      new Events.MeetupNumberOfSeatsUpdated(id, 10),
                                                      new Events.MeetupLocationUpdated(id, "Barcelona"),
                                                      new Events.MeetupPublished(id),
                                                      new Events.MeetupTimeUpdated(id, DateTime.UtcNow, DateTime.UtcNow.AddHours(2))
                                                      ));
        }
Exemplo n.º 10
0
        public void Given_ValidEvents_When_Build_Then_Built()
        {
            var id     = MeetupId.From(Guid.NewGuid());
            var meetup = MeetupAggregate.Build(
                id,
                new Events.MeetupCreated(id, "EventSourcing with Marten"),
                new Events.MeetupNumberOfSeatsUpdated(id, 10),
                new Events.MeetupLocationUpdated(id, "Barcelona"),
                new Events.MeetupTimeUpdated(id, DateTime.UtcNow, DateTime.UtcNow.AddHours(2)),
                new Events.MeetupPublished(id)
                );

            Assert.Equal(id, meetup.Id);
        }
Exemplo n.º 11
0
        public object GetState(Guid id)
        {
            var aggregate = new MeetupAggregate(id);

            return(aggregate.State.ToString());
        }
Exemplo n.º 12
0
 public static MeetupAggregate Canceled(this MeetupAggregate @this) => @this.ExecuteCommand(@this.Cancel);
Exemplo n.º 13
0
 public static MeetupAggregate Closed(this MeetupAggregate @this) => @this.ExecuteCommand(@this.Close);
Exemplo n.º 14
0
 public static MeetupAggregate Published(this MeetupAggregate @this) => @this.ExecuteCommand(@this.Publish);