public void CanRetrieveVersion() { var repository = new AggregateRepository(theStore); var invoice = CreateInvoice(); invoice.Version.ShouldBe(3); repository.Store(invoice); // Assert version was incremented properly var invoiceFromRepository = repository.Load <Invoice>(invoice.Id); invoiceFromRepository.Version.ShouldBe(3); // Update aggregate invoiceFromRepository.AddLine(100, 23, "Some nice product with 23% VAT"); repository.Store(invoiceFromRepository); // Assert version was incremented properly invoiceFromRepository = repository.Load <Invoice>(invoice.Id); invoiceFromRepository.Version.ShouldBe(4); }
public void CanStoreAndHydrateAggregatePreviousVersion() { var repository = new AggregateRepository(theStore); var invoice = CreateInvoice(); repository.Store(invoice); // SAMPLE: scenario-aggregate-versionedload var invoiceFromRepository = repository.Load <Invoice>(invoice.Id, 2); Assert.Equal(124, invoiceFromRepository.Total); // ENDSAMPLE }
public void CanStoreAndHydrateAggregate() { var invoice = CreateInvoice(); // SAMPLE: scenario-aggregate-storeandreadinvoice var repository = new AggregateRepository(theStore); repository.Store(invoice); var invoiceFromRepository = repository.Load <Invoice>(invoice.Id); Assert.Equal(invoice.ToString(), invoiceFromRepository.ToString()); Assert.Equal(invoice.Total, invoiceFromRepository.Total); // ENDSAMPLE }