Example #1
0
        public given_a_read_model_generator()
        {
            var blobStorage = new MemoryBlobStorage();

            this.sut = new PricedOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(dbName));
            this.dao = new OrderDao(() => new ConferenceRegistrationDbContext(dbName), blobStorage, new JsonTextSerializer());
        }
        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 given_a_read_model_generator()
 {
     var blobStorage = new MemoryBlobStorage();
     this.sut = new PricedOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(dbName));
     this.dao = new OrderDao(() => new ConferenceRegistrationDbContext(dbName), blobStorage, new JsonTextSerializer());
 }
 public PricedOrderViewModelUpdater(Func <ConferenceRegistrationDbContext> contextFactory)
 {
     this.innerGenerator = new PricedOrderViewModelGenerator(contextFactory, null, null);
 }