Beispiel #1
0
        public void when_creating_conference_and_seat_then_does_not_publish_seat_created()
        {
            var conference = new ConferenceInfo
            {
                OwnerEmail  = "*****@*****.**",
                OwnerName   = "test owner",
                AccessCode  = "qwerty",
                Name        = "test conference",
                Description = "test conference description",
                Location    = "redmond",
                Slug        = "test",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
            };

            service.CreateConference(conference);

            var seat = new SeatType {
                Name = "seat", Description = "description", Price = 100, Quantity = 100
            };

            service.CreateSeat(conference.Id, seat);

            Assert.Empty(busEvents.OfType <SeatCreated>());
        }
        public static ConferenceInfo PopulateConfereceData(Table table)
        {
            var svc        = new ConferenceService(BuildEventBus());
            var conference = BuildInternalConferenceInfo(table);

            svc.CreateConference(conference);
            svc.Publish(conference.Id);
            // publish seats
            ICollection <SeatType> createdSeats = CreateSeats(table);

            foreach (var seat in createdSeats)
            {
                svc.CreateSeat(conference.Id, seat);
            }

            var created = MessageLogHelper.CollectEvents <AvailableSeatsChanged>(conference.Id, createdSeats.Count);

            if (!created)
            {
                throw new TimeoutException("Conference creation error");
            }

            // Update the confInfo with the created seats

            conference.Seats.AddRange(createdSeats);

            return(conference);
        }
Beispiel #3
0
        public given_an_existing_conference_with_a_seat()
        {
            using (var context = new ConferenceContext(dbName))
            {
                if (context.Database.Exists())
                {
                    context.Database.Delete();
                }

                context.Database.CreateIfNotExists();
            }

            this.busEvents = new List <IEvent>();
            var busMock = new Mock <IEventBus>();

            busMock.Setup(b => b.Publish(It.IsAny <Envelope <IEvent> >())).Callback <Envelope <IEvent> >(e => busEvents.Add(e.Body));
            busMock.Setup(b => b.Publish(It.IsAny <IEnumerable <Envelope <IEvent> > >())).Callback <IEnumerable <Envelope <IEvent> > >(es => busEvents.AddRange(es.Select(e => e.Body)));
            this.service    = new ConferenceService(busMock.Object, this.dbName);
            this.conference = new ConferenceInfo
            {
                OwnerEmail  = "*****@*****.**",
                OwnerName   = "test owner",
                AccessCode  = "qwerty",
                Name        = "test conference",
                Description = "test conference description",
                Location    = "redmond",
                Slug        = "test",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
                IsPublished = true,
                Seats       =
                {
                    new SeatType
                    {
                        Name        = "general",
                        Description = "general description",
                        Price       = 100,
                        Quantity    = 10,
                    }
                }
            };
            service.CreateConference(this.conference);
        }
        public static ConferenceInfo PopulateConfereceData(Table table)
        {
            string conferenceSlug = Slug.CreateNew().Value;
            var svc = new ConferenceService(BuildEventBus());
            var conference = BuildConferenceInfo(table, conferenceSlug);
            svc.CreateConference(conference);
            svc.Publish(conference.Id);

            Registration.ReadModel.Conference published = null;
            while(published == null || 
                !published.IsPublished || 
                published.Seats.Count != table.Rows.Count)
            {
                published = RegistrationHelper.FindConference(conference.Id);
                Thread.Sleep(100);
            }

            return conference;
        }
Beispiel #5
0
        public static ConferenceInfo PopulateConfereceData(Table table)
        {
            var svc = new ConferenceService(BuildEventBus());
            var conference = BuildInternalConferenceInfo(table);
            svc.CreateConference(conference);
            svc.Publish(conference.Id);
            // publish seats
            ICollection<SeatType> createdSeats = CreateSeats(table);
            foreach (var seat in createdSeats)
            {
                svc.CreateSeat(conference.Id, seat);
            }

            var created = MessageLogHelper.CollectEvents<AvailableSeatsChanged>(conference.Id, createdSeats.Count);

            if(!created)
                throw new TimeoutException("Conference creation error");

            // Update the confInfo with the created seats
            
            conference.Seats.AddRange(createdSeats);

            return conference;
        }
        public given_an_existing_conference_with_a_seat()
        {
            using (var context = new ConferenceContext(dbName))
            {
                if (context.Database.Exists())
                    context.Database.Delete();

                context.Database.CreateIfNotExists();
            }

            this.bus = new MemoryEventBus();
            this.service = new ConferenceService(this.bus, this.dbName);
            this.conference = new ConferenceInfo
            {
                OwnerEmail = "*****@*****.**",
                OwnerName = "test owner",
                AccessCode = "qwerty",
                Name = "test conference",
                Description = "test conference description",
                Location = "redmond",
                Slug = "test",
                StartDate = DateTime.UtcNow,
                EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
                IsPublished = true,
                Seats = 
                {
                    new SeatType
                    {
                        Name = "general", 
                        Description = "general description", 
                        Price = 100, 
                        Quantity = 10,
                    }
                }
            };
            service.CreateConference(this.conference);
        }
        public given_an_existing_conference_with_a_seat()
        {
            using (var context = new ConferenceContext(dbName))
            {
                if (context.Database.Exists())
                    context.Database.Delete();

                context.Database.CreateIfNotExists();
            }

            this.busEvents = new List<IEvent>();
            var busMock = new Mock<IEventBus>();
            busMock.Setup(b => b.Publish(It.IsAny<Envelope<IEvent>>())).Callback<Envelope<IEvent>>(e => busEvents.Add(e.Body));
            busMock.Setup(b => b.Publish(It.IsAny<IEnumerable<Envelope<IEvent>>>())).Callback<IEnumerable<Envelope<IEvent>>>(es => busEvents.AddRange(es.Select(e => e.Body)));
            this.service = new ConferenceService(busMock.Object, this.dbName);
            this.conference = new ConferenceInfo
            {
                OwnerEmail = "*****@*****.**",
                OwnerName = "test owner",
                AccessCode = "qwerty",
                Name = "test conference",
                Description = "test conference description",
                Location = "redmond",
                Slug = "test",
                StartDate = DateTime.UtcNow,
                EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
                IsPublished = true,
                Seats = 
                {
                    new SeatType
                    {
                        Name = "general", 
                        Description = "general description", 
                        Price = 100, 
                        Quantity = 10,
                    }
                }
            };
            service.CreateConference(this.conference);
        }
Beispiel #8
0
        public void when_creating_conference_with_existing_slug_then_throws()
        {
            this.conference.Id = Guid.NewGuid();

            Assert.Throws <DuplicateNameException>(() => service.CreateConference(this.conference));
        }
Beispiel #9
0
 public void WhenTheConferenceIsCreated()
 {
     conferenceService.CreateConference(conference);
 }