public ProductIntegrationTests() { sut1 = new EventSourcingRepository <Product, ProductId>( new EventStoreEventStore(EventStoreConnection.Create(new Uri("tcp://localhost:1113"))), new TransientDomainEventPubSub() ); var client = new MongoClient("mongodb://localhost:27017"); mongoDB = client.GetDatabase("cqrs1"); productItemRepository = new MongoDBRepository <ProductDto>(mongoDB); productItemPriceRepository = new MongoDBRepository <ProductPriceDto>(mongoDB); cardEventHandler = new ProductProjection(productItemRepository, productItemPriceRepository); productItemCreatedHandlers = new List <IDomainEventHandler <ProductId, ProductItemCreated> >() { cardEventHandler }; productItemChangedHandlers = new List <IDomainEventHandler <ProductId, ProductItemChanged> >() { cardEventHandler }; productItemPriceChangedHandlers = new List <IDomainEventHandler <ProductId, ProductPriceChanged> >() { cardEventHandler }; }
/// <summary> /// Initializes this instance with JSON data from an API response. /// </summary> /// <param name="data">JSON object</param> public ProductCreatedMessage(dynamic data) : base((object)data) { if (data == null) { return; } this.ProductProjection = new ProductProjection(data.productProjection); }
public async Task ShouldGetProductProjectionByIdAsync() { Response <ProductProjection> response = await _client.ProductProjections().GetProductProjectionByIdAsync(_testProducts[0].Id, true); Assert.True(response.Success); ProductProjection productProjection = response.Result; Assert.NotNull(productProjection.Id); Assert.Equal(productProjection.Id, _testProducts[0].Id); }
/// <summary> /// Initializes this instance with JSON data from an API response. /// </summary> /// <param name="data">JSON object</param> public ProductDeletedMessage(dynamic data) : base((object)data) { if (data == null) { return; } this.RemovedImageUrls = Helper.GetListFromJsonArray <string>(data.removedImageUrls); this.CurrentProjection = new ProductProjection(data.currentProjection); }
private void SetupEventHandlers() { Receive <NewProductAddedToInventory>(e => { var product = new ProductProjection { Id = e.Id, Name = e.Name, Stock = e.Stock, Price = e.Price }; _projection.Inventory.Add(product); Persist(); }); Receive <ProductRestocked>(e => { var product = _projection.Inventory.First(p => p.Id == e.ProductId); product.Stock += e.AmountAdded; Persist(); }); }