コード例 #1
0
        public void Save_IdSet()
        {
            var accountRepo =
                new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testAccount = new Fixture().Create<AccountViewModel>();
            testAccount.Id = 0;

            try
            {
                accountRepo.Save(testAccount);
                testAccount.Id.ShouldBeGreaterThan(0);
            } finally
            {
                accountRepo.Delete(testAccount);
            }
        }
コード例 #2
0
        public void Save_ExistingEntryUpdated()
        {
            var accountRepo =
                new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testAccount = new Fixture().Create<AccountViewModel>();
            testAccount.Id = 0;

            try
            {
                accountRepo.Save(testAccount);
                accountRepo.FindById(testAccount.Id).ShouldNotBeNull();

                const string updatedName = "FOOOOOOOOOO";
                testAccount.Name = updatedName;

                accountRepo.Save(testAccount);
                accountRepo.FindById(testAccount.Id).Name.ShouldBe(updatedName);
            }
            finally
            {
                accountRepo.Delete(testAccount);
            }
        }
コード例 #3
0
        public void GetList_WithoutFilter()
        {
            var accountRepo =
                new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));
            var testAccount = new Fixture().Create<AccountViewModel>();
            testAccount.Id = 0;

            try
            {
                accountRepo.Save(testAccount);
                
                var selectedAccount = accountRepo.GetList().First();

                selectedAccount.Id.ShouldBe(testAccount.Id);
                selectedAccount.Name.ShouldBe(testAccount.Name);
            }
            finally
            {
                accountRepo.Delete(testAccount);
            }
        }
コード例 #4
0
        public void FindById_AccountDeleted()
        {
            var accountRepo =
                new AccountRepository(new DatabaseManager(new WindowsSqliteConnectionFactory(),
                    new MvxWpfFileStore(FILE_ROOT)));

            var testAccount = new Fixture().Create<AccountViewModel>();
            testAccount.Id = 0;

            accountRepo.Save(testAccount);
            var selected = accountRepo.FindById(testAccount.Id);

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

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

            try
            {
                accountRepo.Save(testAccount);

                accountRepo.GetList(x => x.Id == testAccount.Id).First().Id.ShouldBe(testAccount.Id);
                accountRepo.GetList(x => x.Id == 99).FirstOrDefault().ShouldBeNull();
            } finally
            {
                accountRepo.Delete(testAccount);
            }
        }