コード例 #1
0
        public void Save_IdSet()
        {
            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testRecurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            testRecurringPayment.Id = 0;

            try
            {
                recurringPaymentRepository.Save(testRecurringPayment);
                testRecurringPayment.Id.ShouldBeGreaterThan(0);
            }
            finally
            {
                recurringPaymentRepository.Delete(testRecurringPayment);
            }
        }
コード例 #2
0
        public void Save_ExistingEntryUpdated()
        {
            var recPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testRecurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            testRecurringPayment.Id = 0;

            try
            {
                recPaymentRepository.Save(testRecurringPayment);
                recPaymentRepository.FindById(testRecurringPayment.Id).ShouldNotBeNull();

                const string updatedNote = "FOOOOOOOOOO";
                testRecurringPayment.Note = updatedNote;

                recPaymentRepository.Save(testRecurringPayment);
                recPaymentRepository.FindById(testRecurringPayment.Id).Note.ShouldBe(updatedNote);
            }
            finally
            {
                recPaymentRepository.Delete(testRecurringPayment);
            }
        }
コード例 #3
0
        public void GetList_WithoutFilter()
        {
            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testRecurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            testRecurringPayment.Id = 0;

            try
            {
                recurringPaymentRepository.Save(testRecurringPayment);

                var selectedAccount = recurringPaymentRepository.GetList().First();

                selectedAccount.Id.ShouldBe(testRecurringPayment.Id);
                selectedAccount.Amount.ShouldBe(testRecurringPayment.Amount);
            }
            finally
            {
                recurringPaymentRepository.Delete(testRecurringPayment);
            }
        }
コード例 #4
0
        public void FindById_AccountDeleted()
        {
            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));

            var testRecurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            testRecurringPayment.Id = 0;

            recurringPaymentRepository.Save(testRecurringPayment);
            var selected = recurringPaymentRepository.FindById(testRecurringPayment.Id);

            selected.ShouldNotBeNull();
            selected.ShouldBeInstanceOf<RecurringPaymentViewModel>();

            recurringPaymentRepository.Delete(testRecurringPayment);
            recurringPaymentRepository.FindById(testRecurringPayment.Id).ShouldBeNull();
        }
コード例 #5
0
        public void GetList_WithFilter()
        {
            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testRecurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            testRecurringPayment.Id = 0;

            try
            {
                recurringPaymentRepository.Save(testRecurringPayment);

                recurringPaymentRepository.GetList(x => x.Id == testRecurringPayment.Id).First().Id.ShouldBe(testRecurringPayment.Id);
                recurringPaymentRepository.GetList(x => x.Id == 99).FirstOrDefault().ShouldBeNull();
            }
            finally
            {
                recurringPaymentRepository.Delete(testRecurringPayment);
            }
        }
コード例 #6
0
        public void Save_WithRecurringPayment_FkSet()
        {
            var paymentRepository =
                new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));

            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));

            var fixture = new Fixture();

            var recurringPayment = fixture.Create<RecurringPaymentViewModel>();

            recurringPaymentRepository.Save(recurringPayment);
            recurringPayment.Id.ShouldBeGreaterThan(0);

            var testPayment = new Fixture().Create<PaymentViewModel>();
            testPayment.Id = 0;
            testPayment.RecurringPayment = recurringPayment;

            paymentRepository.Save(testPayment);
            paymentRepository.ReloadCache();
            paymentRepository.FindById(testPayment.Id).RecurringPaymentId.ShouldBe(recurringPayment.Id);
        }
コード例 #7
0
        public void SaveAndUpdate_WithRecurringPayment_NoDuplicates()
        {
            var paymentRepository =
                new PaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                new MvxWpfFileStore(FILE_ROOT)));

            var recurringPaymentRepository =
                new RecurringPaymentRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));

            var recurringPayment = new Fixture().Create<RecurringPaymentViewModel>();
            recurringPayment.Id = 0;

            recurringPaymentRepository.Save(recurringPayment);
            paymentRepository.ReloadCache();

            var testPayment = new Fixture().Create<PaymentViewModel>();
            testPayment.Id = 0;

            testPayment.RecurringPayment = recurringPayment;

            paymentRepository.Save(testPayment);
            paymentRepository.Save(testPayment);
            var selected = paymentRepository.FindById(testPayment.Id);

            recurringPaymentRepository.GetList(x => x.Note == testPayment.RecurringPayment.Note).Count().ShouldBe(1);
        }