Esempio n. 1
0
        public void SetDividendsSchedule_OwnStuckIsNull()
        {
            var addDividends = new Dividends()
            {
                ProductSeq = 99
            };

            dividendsRepository.SetDividendsSchedule(addDividends);


            dbConnection.Received().QueryableTransactionRecords.Where(p =>
                                                                      p.ProductSeq == addDividends.ProductSeq && p.SalePrice == null &&
                                                                      p.TransactionTime <= addDividends.ExRightDate.Date);
            //確認沒有進入AddTransaction的重新計算資產的
            dbConnection.DidNotReceive().Modified(Arg.Is <TransactionRecord>(p => p.ProductSeq == addDividends.ProductSeq), EntityState.Added);
            dbConnection.DidNotReceive().QueryableAssets.FirstOrDefault(p => p.ProductSeq == addDividends.ProductSeq);
            dbConnection.DidNotReceive().SaveChanges();
        }
        public void AddNewAsset_Success()
        {
            var product = FakeProduct.StockProduct1;

            assetRepository.AddNewAsset(product);

            dbConnection.Received().QueryableProducts.Any(p => p.ProductSeq == product.ProductSeq);
            dbConnection.Received().QueryableAssets.Any(p => p.ProductSeq == product.ProductSeq);
            dbConnection.Received().Modified(Arg.Is <Asset>(p => p.ProductSeq == product.ProductSeq), EntityState.Added);
            dbConnection.Received().SaveChanges();
        }
Esempio n. 3
0
        public void EditProduct_AddProduct()
        {
            var addproduct = new Product()
            {
                ProductName = "new product", ProductValue = "value", Owner = "owner"
            };


            var except = "Success";
            var actual = productRepository.EditProduct(addproduct);

            Assert.AreEqual(except, actual);

            dbConnection.DidNotReceive().QueryableProducts.FirstOrDefault(p => p.ProductSeq == addproduct.ProductSeq);
            dbConnection.DidNotReceive().Modified(addproduct, EntityState.Modified);
            dbConnection.Received().Modified(addproduct, EntityState.Added);
            dbConnection.Received(1).SaveChanges();
            assetRepository.Received(1).AddNewAsset(addproduct);
        }
Esempio n. 4
0
        public void AddTransactionLog_BuyStock()
        {
            var txViewModel = SetTransactionViewModel(
                false, product, 1000, 10, 50, 0, false);

            var except = "Success";
            var actual = transactionRepository.AddTransactionLog(txViewModel);

            Assert.AreEqual(except, actual);


            CheckBuyReceived(product, txViewModel);
            CheckAssetReceived(product, txViewModel, dbAsset);
            dbConnection.Received().SaveChanges();
        }