public async Task SC02_DomainAsync() { var eventStore = new CosmosDBEventStore(EndpointUri, AuthKey, Database); // Request parameters. var meterId = "2"; var postalCode = "111 64"; var houseNumber = "4"; var activationCode = "supersecret"; // 1. New domain object. var meter = new Meter(meterId, postalCode, houseNumber, activationCode); var repository = new MeterRepository(eventStore); var succes = await repository.SaveMeterAsync(meter); Assert.IsTrue(succes, "Unexpected stream version encountered."); // 2. Call business logic on domain object. meter = await repository.LoadMeterAsync(meterId); meter.Activate(activationCode); succes = await repository.SaveMeterAsync(meter); Assert.IsTrue(succes, "Unexpected stream version encountered."); }
public async Task SC06A_SaveSnapshotAsync() { IEventStore eventStore = new CosmosEventStore(this, EndpointUrl, AuthorizationKey, DatabaseId); ISnapshotStore snapshotStore = new CosmosSnapshotStore(EndpointUrl, AuthorizationKey, DatabaseId); // Request parameters. var meterId = "87000001"; // Load domain object. var repository = new MeterRepository(eventStore); var meter = await repository.LoadMeterAsync(meterId); var snapshot = meter.GetSnapshot(); await snapshotStore.SaveSnapshotAsync($"meter:{meterId}", meter.Version, snapshot); }
public async Task SC03_DomainAddAsync() { var eventStore = new CosmosDBEventStore(EndpointUri, AuthKey, Database); // Request parameters. var meterId = "87000002"; var postalCode = "9999 BB"; var houseNumber = "4"; var activationCode = "supersecret"; // New domain object. var meter = new Meter(meterId, postalCode, houseNumber, activationCode); var repository = new MeterRepository(eventStore); var succes = await repository.SaveMeterAsync(meter); Assert.IsTrue(succes, "Unexpected stream version encountered."); }
public async Task SC04_DomainUpdateAsync() { var eventStore = new CosmosDBEventStore(EndpointUri, AuthKey, Database); // Request parameters. var meterId = "87000002"; var activationCode = "supersecret"; // Load domain object. var repository = new MeterRepository(eventStore); var meter = await repository.LoadMeterAsync(meterId); // Call business logic on domain object. meter.Activate(activationCode); var succes = await repository.SaveMeterAsync(meter); Assert.IsTrue(succes, "Unexpected stream version encountered."); }