public async void Update_NoNewEntryAdded()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var repository = new RecurringPaymentRepository(dbFactory);

            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(1, repository.GetAll().Count());
        }
        public async void Update_IdUnchanged()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var repository = new RecurringPaymentRepository(dbFactory);

            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            var idBeforeUpdate = testEntry.Id;

            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            Assert.Equal(idBeforeUpdate, testEntry.Id);
        }
        public async void Update_EntryUpdated()
        {
            // Arrange
            var unitOfWork = new UnitOfWork(dbFactory);

            var repository = new RecurringPaymentRepository(dbFactory);

            var newValue  = "newText";
            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = new AccountEntity {
                    Name = "testAccount"
                },
                Note = "Testtext"
            };

            // Act
            repository.Add(testEntry);
            await unitOfWork.Commit();

            testEntry.Note = newValue;
            repository.Update(testEntry);
            await unitOfWork.Commit();

            // Assert
            var loadedEntry = await repository.GetById(testEntry.Id);

            Assert.Equal(newValue, loadedEntry.Note);
        }
        public async void Update_EntryUpdated()
        {
            // Arrange
            var recurringPaymentRepository = new RecurringPaymentRepository(ambientDbContextLocator);
            var accountRepository          = new AccountRepository(ambientDbContextLocator);

            AccountEntity testAccount;

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                testAccount = new AccountEntity {
                    Name = "testAccount"
                };
                accountRepository.Add(testAccount);
                await dbContextScope.SaveChangesAsync();
            }

            var newValue  = "newText";
            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = testAccount,
                Note           = "Testtext"
            };

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                recurringPaymentRepository.Add(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Act
            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                testEntry.Note = newValue;
                recurringPaymentRepository.Update(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Assert
            using (dbContextScopeFactory.CreateReadOnly())
            {
                var loadedEntry = await recurringPaymentRepository.GetById(testEntry.Id);

                Assert.Equal(newValue, loadedEntry.Note);
            }
        }
        public async void Update_NoNewEntryAdded()
        {
            // Arrange
            var recurringPaymentRepository = new RecurringPaymentRepository(ambientDbContextLocator);
            var accountRepository          = new AccountRepository(ambientDbContextLocator);

            AccountEntity testAccount;

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                testAccount = new AccountEntity {
                    Name = "testAccount"
                };
                accountRepository.Add(testAccount);
                await dbContextScope.SaveChangesAsync();
            }

            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = testAccount,
                Note           = "Testtext"
            };

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                recurringPaymentRepository.Add(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Act
            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                recurringPaymentRepository.Update(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Assert
            using (dbContextScopeFactory.CreateReadOnly())
            {
                Assert.Equal(1, recurringPaymentRepository.GetAll().Count());
            }
        }
        public async void Update_IdUnchanged()
        {
            // Arrange
            var recurringPaymentRepository = new RecurringPaymentRepository(ambientDbContextLocator);
            var accountRepository          = new AccountRepository(ambientDbContextLocator);

            AccountEntity testAccount;

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                testAccount = new AccountEntity {
                    Name = "testAccount"
                };
                accountRepository.Add(testAccount);
                await dbContextScope.SaveChangesAsync();
            }

            var testEntry = new RecurringPaymentEntity
            {
                ChargedAccount = testAccount,
                Note           = "Testtext"
            };

            int idBeforeUpdate;

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                recurringPaymentRepository.Add(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Act
            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                idBeforeUpdate = testEntry.Id;
                recurringPaymentRepository.Update(testEntry);
                await dbContextScope.SaveChangesAsync();
            }

            // Assert
            Assert.Equal(idBeforeUpdate, testEntry.Id);
        }