public void when_seat_created_then_adds_seat() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set <SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(0, dto.AvailableQuantity); Assert.Equal(-1, dto.SeatsAvailabilityVersion); } }
public void when_conference_updated_then_conference_dto_populated() { var startDate = new DateTimeOffset(2012, 04, 20, 15, 0, 0, TimeSpan.FromHours(-8)); sut.Handle(new ConferenceUpdated { Name = "newname", Description = "newdescription", Slug = "newtest", Owner = new Owner { Name = "owner", Email = "*****@*****.**" }, SourceId = conferenceId, StartDate = startDate.UtcDateTime, EndDate = DateTime.UtcNow.Date }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Find <Registration.ReadModel.Conference>(conferenceId); Assert.NotNull(dto); Assert.Equal("newname", dto.Name); Assert.Equal("newdescription", dto.Description); Assert.Equal("newtest", dto.Code); Assert.Equal(startDate, dto.StartDate); } }
public void Setup() { this._dbName = this.GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } var blobStorage = new MemoryBlobStorage(); this._sut = new DraftOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(_dbName)); this._dao = new OrderDao(() => new ConferenceRegistrationDbContext(_dbName), blobStorage, new JsonTextSerializer()); System.Diagnostics.Trace.Listeners.Clear(); this._orderPlacedEvent = new OrderPlaced { SourceId = Guid.NewGuid(), ConferenceId = Guid.NewGuid(), AccessCode = "asdf", Seats = new[] { new SeatQuantity(Guid.NewGuid(), 5) }, Version = 1 }; _sut.Handle(_orderPlacedEvent); }
public void when_available_seats_change_then_updates_remaining_quantity() { var seatId = Guid.NewGuid(); sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200 }); sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 1, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set <SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(200, dto.AvailableQuantity); Assert.Equal(1, dto.SeatsAvailabilityVersion); } }
public void when_seat_updated_then_updates_seat_on_conference_dto() { var seatId = Guid.NewGuid(); sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200 }); sut.Handle(new SeatUpdated { ConferenceId = conferenceId, SourceId = seatId, Name = "newseat", Description = "newdescription", Price = 100 }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set <SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.NotNull(dto); Assert.Equal("newseat", dto.Name); Assert.Equal("newdescription", dto.Description); Assert.Equal(100, dto.Price); Assert.Equal(-1, dto.SeatsAvailabilityVersion); } }
public void When_conference_created_then_conference_dto_populated() { var conferenceId = Guid.NewGuid(); this._sut.Handle(new ConferenceCreated { Name = "name", Description = "description", Slug = "test", Owner = new Owner { Name = "owner", Email = "*****@*****.**", }, SourceId = conferenceId, StartDate = DateTime.UtcNow.Date, EndDate = DateTime.UtcNow.Date, }); using (var context = new ConferenceRegistrationDbContext(_dbName)) { var dto = context.Find <Conference>(conferenceId); Assert.NotNull(dto); Assert.AreEqual("name", dto.Name); Assert.AreEqual("description", dto.Description); Assert.AreEqual("test", dto.Code); } }
public void When_seat_created_even_when_conference_created_was_not_handled_then_creates_seat() { var conferenceId = Guid.NewGuid(); var seatId = Guid.NewGuid(); this._sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); using (var context = new ConferenceRegistrationDbContext(_dbName)) { var dto = context.Set <SeatType>() .FirstOrDefault(x => x.Id == seatId); Assert.NotNull(dto); Assert.AreEqual("seat", dto.Name); Assert.AreEqual("description", dto.Description); Assert.AreEqual(conferenceId, dto.ConferenceId); Assert.AreEqual(200, dto.Price); Assert.AreEqual(0, dto.AvailableQuantity); } }
public void when_conference_created_then_conference_dto_populated() { var conferenceId = Guid.NewGuid(); this.sut.Handle(new ConferenceCreated { Name = "name", Description = "description", Slug = "test", Owner = new Owner { Name = "owner", Email = "*****@*****.**", }, SourceId = conferenceId, StartDate = DateTime.UtcNow.Date, EndDate = DateTime.UtcNow.Date, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Find<Conference>(conferenceId); Assert.NotNull(dto); Assert.Equal("name", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal("test", dto.Code); } }
public static T FindInContext <T>(Guid id) where T : class { using (var context = new ConferenceRegistrationDbContext(ConferenceRegistrationDbContext.SchemaName)) { return(context.Find <T>(id)); } }
public void Dispose() { using (var context = new ConferenceRegistrationDbContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); } }
private static void Main(string[] args) { var connectionString = ConfigurationManager.AppSettings["defaultConnection"]; if (args.Length > 0) { connectionString = args[0]; } // Use ConferenceContext as entry point for dropping and recreating DB using (var context = new ConferenceContext()) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } Database.SetInitializer <EventStoreDbContext>(null); Database.SetInitializer <MessageLogDbContext>(null); Database.SetInitializer <BlobStorageDbContext>(null); Database.SetInitializer <ConferenceRegistrationDbContext>(null); Database.SetInitializer <RegistrationProcessManagerDbContext>(null); Database.SetInitializer <PaymentsDbContext>(null); DbContext[] contexts = { new EventStoreDbContext(connectionString), new MessageLogDbContext(connectionString), new BlobStorageDbContext(connectionString), new PaymentsDbContext(connectionString), new RegistrationProcessManagerDbContext(connectionString), new ConferenceRegistrationDbContext(connectionString) }; foreach (var context in contexts) { var adapter = (IObjectContextAdapter)context; var script = adapter.ObjectContext.CreateDatabaseScript(); context.Database.ExecuteSqlCommand(script); context.Dispose(); } using (var context = new ConferenceRegistrationDbContext(connectionString)) { ConferenceRegistrationDbContextInitializer.CreateIndexes(context); } using (var context = new RegistrationProcessManagerDbContext(connectionString)) { RegistrationProcessManagerDbContextInitializer.CreateIndexes(context); } using (var context = new PaymentsDbContext(connectionString)) { PaymentsReadDbContextInitializer.CreateViews(context); } MessagingDbInitializer.CreateDatabaseObjects(connectionString, "SqlBus"); }
public void Setup() { this._dbName = this.GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } var blobStorage = new MemoryBlobStorage(); this._sut = new PricedOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(_dbName)); this._dao = new OrderDao(() => new ConferenceRegistrationDbContext(_dbName), blobStorage, new JsonTextSerializer()); this._seatCreatedEvents = new[] { new SeatCreated { SourceId = Guid.NewGuid(), Name = "General" }, new SeatCreated { SourceId = Guid.NewGuid(), Name = "Precon" } }; this._sut.Handle(this._seatCreatedEvents[0]); this._sut.Handle(this._seatCreatedEvents[1]); this._orderPlaced = new OrderPlaced { SourceId = _orderId, ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10), Version = 2, }; this._sut.Handle(_orderPlaced); this._sut.Handle(new OrderTotalsCalculated { SourceId = _orderId, Lines = new[] { new SeatOrderLine { LineTotal = 50, SeatType = this._seatCreatedEvents[0].SourceId, Quantity = 10, UnitPrice = 5 }, }, Total = 50, IsFreeOfCharge = true, Version = 4, }); this._dto = this._dao.FindPricedOrder(_orderId); }
public void Dispose() { using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } } }
public given_a_read_model_database() { dbName = this.GetType().Name + "-" + Guid.NewGuid().ToString(); using (var context = new ConferenceRegistrationDbContext(dbName)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.Create(); } }
public given_a_read_model_database() { dbName = GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } }
public void when_seat_availability_update_event_has_version_lower_than_last_update_then_event_is_ignored() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 0, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); this.sut.Handle(new SeatsReserved { SourceId = conferenceId, Version = 1, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = -50 } } }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 0, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set <SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(150, dto.AvailableQuantity); Assert.Equal(1, dto.SeatsAvailabilityVersion); } }
public void when_conference_published_then_conference_dto_updated() { var startDate = new DateTimeOffset(2012, 04, 20, 15, 0, 0, TimeSpan.FromHours(-8)); sut.Handle(new ConferencePublished { SourceId = conferenceId }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Find <Registration.ReadModel.Conference>(conferenceId); Assert.NotNull(dto); Assert.Equal(true, dto.IsPublished); } }
public void When_published_conference_unpublished_then_conference_dto_updated() { this._sut.Handle(new ConferencePublished { SourceId = _conferenceId, }); this._sut.Handle(new ConferenceUnpublished { SourceId = _conferenceId, }); using (var context = new ConferenceRegistrationDbContext(_dbName)) { var dto = context.Find <Conference>(_conferenceId); Assert.NotNull(dto); Assert.AreEqual(false, dto.IsPublished); } }
private List <PricedOrderLineSeatTypeDescription> GetSeatTypeDescriptions(IEnumerable <Guid> seatTypeIds, ConferenceRegistrationDbContext context) { var result = new List <PricedOrderLineSeatTypeDescription>(); var notCached = new List <Guid>(); PricedOrderLineSeatTypeDescription cached; foreach (var seatTypeId in seatTypeIds) { cached = (PricedOrderLineSeatTypeDescription)this._seatDescriptionsCache.Get("SeatDescription_" + seatTypeId); if (cached == null) { notCached.Add(seatTypeId); } else { result.Add(cached); } } if (notCached.Count > 0) { var notCachedArray = notCached.ToArray(); var seatTypeDescriptions = context.Query <PricedOrderLineSeatTypeDescription>() .Where(x => notCachedArray.Contains(x.SeatTypeId)).ToList(); foreach (var seatType in seatTypeDescriptions) { var desc = (PricedOrderLineSeatTypeDescription) this._seatDescriptionsCache.AddOrGetExisting("SeatDescription_" + seatType.SeatTypeId, seatType, new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5) }) ?? seatType; result.Add(desc); } } return(result); }
public void When_seats_are_released_then_updates_remaining_quantity() { var seatId = Guid.NewGuid(); this._sut.Handle(new SeatCreated { ConferenceId = _conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this._sut.Handle(new AvailableSeatsChanged { SourceId = _conferenceId, Version = 1, Seats = new[] { new SeatQuantity(seatId, 200) } }); this._sut.Handle(new SeatsReserved { SourceId = _conferenceId, Version = 2, AvailableSeatsChanged = new[] { new SeatQuantity(seatId, -50) } }); this._sut.Handle(new SeatsReservationCancelled { SourceId = _conferenceId, Version = 3, AvailableSeatsChanged = new[] { new SeatQuantity(seatId, 50) } }); using (var context = new ConferenceRegistrationDbContext(_dbName)) { var dto = context.Set <SeatType>() .Where(x => x.ConferenceId == _conferenceId) .Single(x => x.Id == seatId); Assert.AreEqual("seat", dto.Name); Assert.AreEqual("description", dto.Description); Assert.AreEqual(200, dto.Price); Assert.AreEqual(200, dto.AvailableQuantity); Assert.AreEqual(3, dto.SeatsAvailabilityVersion); } }
public void Setup() { this._dbName = this.GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } var bus = new Mock <ICommandBus>(); bus.Setup(x => x.Send(It.IsAny <Envelope <ICommand> >())) .Callback <Envelope <ICommand> >(x => this._commands.Add(x.Body)); bus.Setup(x => x.Send(It.IsAny <IEnumerable <Envelope <ICommand> > >())) .Callback <IEnumerable <Envelope <ICommand> > >(x => this._commands.AddRange(x.Select(e => e.Body))); this._sut = new ConferenceViewModelGenerator(() => new ConferenceRegistrationDbContext(_dbName), bus.Object); }
public void Setup() { this._dbName = this.GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } _commands = new List <ICommand>(); var bus = new Mock <ICommandBus>(); bus.Setup(x => x.Send(It.IsAny <Envelope <ICommand> >())) .Callback <Envelope <ICommand> >(x => this._commands.Add(x.Body)); bus.Setup(x => x.Send(It.IsAny <IEnumerable <Envelope <ICommand> > >())) .Callback <IEnumerable <Envelope <ICommand> > >(x => this._commands.AddRange(x.Select(e => e.Body))); this._sut = new ConferenceViewModelGenerator(() => new ConferenceRegistrationDbContext(_dbName), bus.Object); System.Diagnostics.Trace.Listeners.Clear(); this._sut.Handle(new ConferenceCreated { SourceId = _conferenceId, Name = "name", Description = "description", Slug = "test", Owner = new Owner { Name = "owner", Email = "*****@*****.**", }, StartDate = DateTime.UtcNow.Date, EndDate = DateTime.UtcNow.Date, }); }
public void Setup() { this._dbName = this.GetType().Name + "-" + Guid.NewGuid(); using (var context = new ConferenceRegistrationDbContext(this._dbName)) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } var conferenceDao = new Mock <IConferenceDao>(); conferenceDao.Setup(x => x.GetSeatTypeNames(It.IsAny <IEnumerable <Guid> >())) .Returns(SeatTypes); var blobs = new MemoryBlobStorage(); this.dao = new OrderDao(() => new ConferenceRegistrationDbContext(_dbName), blobs, new JsonTextSerializer()); this.sut = new SeatAssignmentsViewModelGenerator(conferenceDao.Object, blobs, new JsonTextSerializer()); this.sut.Handle(new SeatAssignmentsCreated { SourceId = AssignmentsId, OrderId = OrderId, Seats = new[] { new SeatAssignmentsCreated.SeatAssignmentInfo { Position = 0, SeatType = SeatTypes[0].Id }, new SeatAssignmentsCreated.SeatAssignmentInfo { Position = 1, SeatType = SeatTypes[1].Id }, } }); }
public void when_seats_are_released_then_updates_remaining_quantity() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 1, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); this.sut.Handle(new SeatsReserved { SourceId = conferenceId, Version = 2, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = -50 } } }); this.sut.Handle(new SeatsReservationCancelled { SourceId = conferenceId, Version = 3, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = 50 } } }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(200, dto.AvailableQuantity); Assert.Equal(3, dto.SeatsAvailabilityVersion); } }
static void Main(string[] args) { var connectionString = ConfigurationManager.AppSettings["defaultConnection"]; if (args.Length > 0) { connectionString = args[0]; } // Use ConferenceContext as entry point for dropping and recreating DB using (var context = new ConferenceContext(connectionString)) { if (context.Database.Exists()) context.Database.Delete(); context.Database.Create(); } Database.SetInitializer<EventStoreDbContext>(null); Database.SetInitializer<MessageLogDbContext>(null); Database.SetInitializer<BlobStorageDbContext>(null); Database.SetInitializer<ConferenceRegistrationDbContext>(null); Database.SetInitializer<RegistrationProcessManagerDbContext>(null); Database.SetInitializer<PaymentsDbContext>(null); DbContext[] contexts = new DbContext[] { new EventStoreDbContext(connectionString), new MessageLogDbContext(connectionString), new BlobStorageDbContext(connectionString), new PaymentsDbContext(connectionString), new RegistrationProcessManagerDbContext(connectionString), new ConferenceRegistrationDbContext(connectionString), }; foreach (DbContext context in contexts) { var adapter = (IObjectContextAdapter)context; var script = adapter.ObjectContext.CreateDatabaseScript(); context.Database.ExecuteSqlCommand(script); context.Dispose(); } using (var context = new ConferenceRegistrationDbContext(connectionString)) { ConferenceRegistrationDbContextInitializer.CreateIndexes(context); } using (var context = new RegistrationProcessManagerDbContext(connectionString)) { RegistrationProcessManagerDbContextInitializer.CreateIndexes(context); } using (var context = new PaymentsDbContext(connectionString)) { PaymentsReadDbContextInitializer.CreateViews(context); } MessagingDbInitializer.CreateDatabaseObjects(connectionString, "SqlBus"); }
public void when_seat_created_then_adds_seat_to_conference_dto() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<Conference>() .Where(x => x.Id == conferenceId) .SelectMany(x => x.Seats) .FirstOrDefault(x => x.Id == seatId); Assert.NotNull(dto); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(0, dto.AvailableQuantity); } }
public void when_seat_availability_update_event_has_version_equal_to_last_update_then_event_is_ignored() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 0, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); this.sut.Handle(new SeatsReserved { SourceId = conferenceId, Version = 1, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = -50 } } }); this.sut.Handle(new SeatsReserved { SourceId = conferenceId, Version = 1, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = -50 } } }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dtos = context.Set<Conference>() .Where(x => x.Id == conferenceId) .SelectMany(x => x.Seats, (Conference, Seat) => new { Conference, Seat }) .FirstOrDefault(x => x.Seat.Id == seatId); Assert.NotNull(dtos); Assert.Equal("seat", dtos.Seat.Name); Assert.Equal("description", dtos.Seat.Description); Assert.Equal(200, dtos.Seat.Price); Assert.Equal(150, dtos.Seat.AvailableQuantity); Assert.Equal(1, dtos.Conference.SeatsAvailabilityVersion); } }
public void when_published_conference_unpublished_then_conference_dto_updated() { var startDate = new DateTimeOffset(2012, 04, 20, 15, 0, 0, TimeSpan.FromHours(-8)); this.sut.Handle(new ConferencePublished { SourceId = conferenceId, }); this.sut.Handle(new ConferenceUnpublished { SourceId = conferenceId, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Find<Conference>(conferenceId); Assert.NotNull(dto); Assert.Equal(false, dto.IsPublished); } }
public void when_seat_created_even_when_conference_created_was_not_handled_then_creates_seat() { var conferenceId = Guid.NewGuid(); var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<SeatType>() .FirstOrDefault(x => x.Id == seatId); Assert.NotNull(dto); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(conferenceId, dto.ConferenceId); Assert.Equal(200, dto.Price); Assert.Equal(0, dto.AvailableQuantity); } }
public void when_seat_updated_then_updates_seat_on_conference_dto() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this.sut.Handle(new SeatUpdated { ConferenceId = conferenceId, SourceId = seatId, Name = "newseat", Description = "newdescription", Price = 100, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.NotNull(dto); Assert.Equal("newseat", dto.Name); Assert.Equal("newdescription", dto.Description); Assert.Equal(100, dto.Price); Assert.Equal(-1, dto.SeatsAvailabilityVersion); } }
public void when_conference_updated_then_conference_dto_populated() { var startDate = new DateTimeOffset(2012, 04, 20, 15, 0, 0, TimeSpan.FromHours(-8)); this.sut.Handle(new ConferenceUpdated { Name = "newname", Description = "newdescription", Slug = "newtest", Owner = new Owner { Name = "owner", Email = "*****@*****.**", }, SourceId = conferenceId, StartDate = startDate.UtcDateTime, EndDate = DateTime.UtcNow.Date, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Find<Conference>(conferenceId); Assert.NotNull(dto); Assert.Equal("newname", dto.Name); Assert.Equal("newdescription", dto.Description); Assert.Equal("newtest", dto.Code); Assert.Equal(startDate, dto.StartDate); } }
public void when_seat_availability_update_event_has_version_lower_than_last_update_then_event_is_ignored() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 0, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); this.sut.Handle(new SeatsReserved { SourceId = conferenceId, Version = 1, AvailableSeatsChanged = new[] { new SeatQuantity { SeatType = seatId, Quantity = -50 } } }); this.sut.Handle(new AvailableSeatsChanged { SourceId = conferenceId, Version = 0, Seats = new[] { new SeatQuantity { SeatType = seatId, Quantity = 200 } } }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(150, dto.AvailableQuantity); Assert.Equal(1, dto.SeatsAvailabilityVersion); } }
public void when_seat_created_then_adds_seat() { var seatId = Guid.NewGuid(); this.sut.Handle(new SeatCreated { ConferenceId = conferenceId, SourceId = seatId, Name = "seat", Description = "description", Price = 200, }); using (var context = new ConferenceRegistrationDbContext(dbName)) { var dto = context.Set<SeatType>() .Where(x => x.ConferenceId == conferenceId) .Single(x => x.Id == seatId); Assert.Equal("seat", dto.Name); Assert.Equal("description", dto.Description); Assert.Equal(200, dto.Price); Assert.Equal(0, dto.AvailableQuantity); Assert.Equal(-1, dto.SeatsAvailabilityVersion); } }