Example #1
0
        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.");
        }