Exemple #1
0
        public void When_calling_Save_it_will_add_the_domain_events_to_the_domain_event_storage()
        {
            var client = Client.CreateNew(new ClientName("New Client"), new Address("Street", "123", "5000", "Bergen"), new PhoneNumber("1234567890"));

            client.UpdatePhoneNumber(new PhoneNumber("1234567890"));
            client.UpdatePhoneNumber(new PhoneNumber("1234567890"));

            _repository.Add(client);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetEventsSinceLastSnapShot(client.Id).Count(), Is.EqualTo(3));
            Assert.That(_domainEventStorage.GetAllEvents(client.Id).Count(), Is.EqualTo(3));
        }
        public void When_calling_Save_it_will_add_the_domain_events_to_the_domain_event_storage()
        {
            var activeAccount = ActiveAccount.CreateNew(Guid.NewGuid(), "AccountName");

            activeAccount.Deposite(new Amount(1));
            activeAccount.Deposite(new Amount(1));

            _repository.Add(activeAccount);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetEventsSinceLastSnapShot(activeAccount.Id).Count(), Is.EqualTo(3));
            Assert.That(_domainEventStorage.GetAllEvents(activeAccount.Id).Count(), Is.EqualTo(3));
        }
        public void When_calling_Save_it_will_add_the_domain_events_to_the_domain_event_storage()
        {
            _ledgers = new List <Ledger>
            {
                new CreditMutation(1, new AccountNumber("0987654321")),
                new DebitMutation(1, new AccountNumber("0987654321")),
                new CreditTransfer(1, new AccountNumber("0987654321")),
                new DebitTransfer(1, new AccountNumber("0987654321")),
                new DebitTransferFailed(1, new AccountNumber("0987654321")),
            };

            var closedAccount = ClosedAccount.CreateNew(Guid.NewGuid(), Guid.NewGuid(), _ledgers, new AccountName("AccountName"), new AccountNumber("1234567890"));

            _repository.Add(closedAccount);
            _eventStoreUnitOfWork.Commit();

            Assert.That(_domainEventStorage.GetEventsSinceLastSnapShot(closedAccount.Id).Count(), Is.EqualTo(1));
            Assert.That(_domainEventStorage.GetAllEvents(closedAccount.Id).Count(), Is.EqualTo(1));
        }