示例#1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();

            using (var db = new BDD_Demo_Lib.Data.BDD_Demo_Context(configuration.GetConnectionString("MyDb")))
            {
                //Todo use db
                var bankAccount = db.BankAccounts.FirstOrDefault();
                Console.WriteLine($"BankAccountId:{bankAccount.Id}, Balance:{bankAccount.Balance}, Name:{bankAccount.Name}");

                var logic = new BDD_Demo_Lib.BankAccountLogic(db);
                logic.Deposit(1, 80);

                Console.WriteLine($"Deposit 80 into Id 1");

                Console.WriteLine($"BankAccountId:{bankAccount.Id}, Balance:{bankAccount.Balance}, Name:{bankAccount.Name}");

                Console.WriteLine($"Withdraw 70 from Id 1");

                logic.Withdraw(1, 70);

                Console.WriteLine($"BankAccountId:{bankAccount.Id}, Balance:{bankAccount.Balance}, Name:{bankAccount.Name}");
            }
        }
示例#2
0
        public void DepositShouldReturn100GivenId2And50Deposit()
        {
            // Arrange
            var logic = new BDD_Demo_Lib.BankAccountLogic(_context);

            // Act
            decimal balance = logic.Deposit(2, 50);

            // Assert
            balance.Should().Be(100);
        }
示例#3
0
        public void DepositShouldReturnExceptionWhenBankAccountIdNotFound()
        {
            // Arrange
            var logic = new BDD_Demo_Lib.BankAccountLogic(_context);

            // Act
            Action act = () => logic.Deposit(4, 100);

            // Assert
            act.Should().Throw <System.NullReferenceException>();
        }