Exemplo n.º 1
0
        private FinancialRepository GetRepository()
        {
            var options = CreateNewContextOptions();

            _dbContext = new FinancialDbContext(options);
            return(new FinancialRepository(_dbContext));
        }
Exemplo n.º 2
0
 private void Setup_FakeDbContext(
     List <Asset> fakeAssetList,
     List <AssetType> fakeAssetTypeList)
 {
     // setup dbContext
     _fakeDbContext = MockFinancialDbContext.Create(
         assets: fakeAssetList,
         assetTypes: fakeAssetTypeList);
 }
Exemplo n.º 3
0
        private void Setup_Service_FakeUnitOfWork(List <TransactionCategory> fakeTransactionCategories)
        {
            // setup DbContext
            _fakeDbContext = MockFinancialDbContext.Create(transactionCategories: fakeTransactionCategories);

            // set up uow
            _fakeUnitOfWork = new UnitOfWork(_fakeDbContext);

            // set up repository
            _service = new AccountTransactionService(_fakeUnitOfWork);
        }
Exemplo n.º 4
0
        private void Setup_Service_FakeUnitOfWork(
            List <Asset> fakeAssets,
            List <AssetSetting> fakeAssetSettings,
            List <AssetType> fakeAssetTypes,
            List <SettingType> fakeSettingTypes)
        {
            // setup DbContext
            _fakeDbContext = MockFinancialDbContext.Create(
                assets: fakeAssets,
                assetSettings: fakeAssetSettings,
                assetTypes: fakeAssetTypes,
                settingTypes: fakeSettingTypes);

            // set up uow
            _fakeUnitOfWork = new UnitOfWork(_fakeDbContext);

            // set up repository
            _service = new AccountTransactionService(_fakeUnitOfWork);
        }
Exemplo n.º 5
0
 private void Setup_FakeDbContext(
     List <Asset> fakeAssetList,
     List <AssetSetting> fakeAssetSettingList,
     List <AssetTransaction> fakeAssetTransactionList,
     List <AssetType> fakeAssetTypeList,
     List <SettingType> fakeSettingTypeList,
     List <TransactionCategory> fakeTransactionCategoryList,
     List <TransactionDescription> fakeTransactionDescriptionList,
     List <TransactionType> fakeTransactionTypeList)
 {
     _fakeDbContext = MockFinancialDbContext.Create(
         assets: fakeAssetList,
         assetSettings: fakeAssetSettingList,
         assetTransactions: fakeAssetTransactionList,
         assetTypes: fakeAssetTypeList,
         settingTypes: fakeSettingTypeList,
         transactionCategories: fakeTransactionCategoryList,
         transactionDescriptions: fakeTransactionDescriptionList,
         transactionTypes: fakeTransactionTypeList);
 }
Exemplo n.º 6
0
        public static void PopulateTestData(FinancialDbContext dbContext)
        {
            var accounts = dbContext.Accounts;

            foreach (var acc in accounts)
            {
                dbContext.Remove(acc);
            }
            dbContext.SaveChanges();
            dbContext.Accounts.Add(new Account()
            {
                Name    = "Test Acc 1",
                Balance = 500
            });
            dbContext.Accounts.Add(new Account()
            {
                Name    = "Test Acc 2",
                Balance = 99999
            });
            dbContext.SaveChanges();
        }
Exemplo n.º 7
0
        public void Add_WhenAssetProvided_AddEntityToDbContext_Test()
        {
            // Arrange
            _fakeDbContext = new FinancialDbContext();

            _repository = new AssetRepository(_fakeDbContext);

            var expectedAsset = new Asset { /*Id = 1,*/
                AssetTypeId = 2, Name = "b", IsActive = true
            };

            // Act
            _repository.Add(expectedAsset);
            var actualAsset = _fakeDbContext.Assets.Local.ToList()[0];

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(actualAsset.Id, Is.EqualTo(0), "Asset Id");
                Assert.That(actualAsset.Name, Is.EqualTo(expectedAsset.Name), "Asset Name");
                Assert.That(actualAsset.AssetTypeId, Is.EqualTo(expectedAsset.AssetTypeId), "AssetType Id");
                Assert.That(actualAsset.IsActive, Is.EqualTo(expectedAsset.IsActive), "IsActive");
            });
        }
Exemplo n.º 8
0
 private void Setup_FakeDbContext(List <TransactionCategory> fakeTransactionCategoryList)
 {
     // setup dbContext
     _fakeDbContext = MockFinancialDbContext.Create(transactionCategories: fakeTransactionCategoryList);
 }
 public FinancialRepository(FinancialDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 10
0
 public RelationshipTypeRepository(FinancialDbContext context)
     : base(context)
 {
 }
Exemplo n.º 11
0
 public TransactionTypeRepository(FinancialDbContext context)
     : base(context)
 {
 }
 public FinancialTransactionRepository(FinancialDbContext db)
 {
     Db = db;
 }
 public AssetTransactionRepository(FinancialDbContext context)
     : base(context)
 {
 }
 public AssetRelationshipRepository(FinancialDbContext context)
     : base(context)
 {
 }
Exemplo n.º 15
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public BLLBase()
        {
            string connStr = DBConfig.Current[CONN_KEY];

            dbContext = new FinancialDbContext(connStr);
        }
Exemplo n.º 16
0
 public UnitOfWork(FinancialDbContext context)
 {
     _context = context;
     SetRepositories();
 }
Exemplo n.º 17
0
 public UnitOfWork()
 {
     _context = new FinancialDbContext();
     SetRepositories();
 }
Exemplo n.º 18
0
 public AssetSettingRepository(FinancialDbContext context)
     : base(context)
 {
 }
Exemplo n.º 19
0
 public TransactionCategoryRepository(FinancialDbContext context)
     : base(context)
 {
 }
Exemplo n.º 20
0
 public AssetTypeSettingTypeRepository(FinancialDbContext context)
     : base(context)
 {
 }
 public TransactionDescriptionRepository(FinancialDbContext context)
     : base(context)
 {
 }