Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace UnitTesting
- {
- public class BanckAccount
- {
- public BanckAccount(decimal balance)
- {
- this.Balance = balance;
- }
- private decimal balance;
- public decimal Balance
- {
- get
- {
- return this.balance;
- }
- private set
- {
- if (value < 0)
- {
- throw new ArgumentException("Balance can not be negative.");
- }
- balance = value;
- }
- }
- public void Deposit(decimal sum)
- {
- if (sum <= 0)
- {
- throw new ArgumentException("Sum must be positive number.");
- }
- Balance += sum;
- }
- public void Withdraw(decimal sum)
- {
- if (sum <= 0)
- {
- throw new ArgumentException("Sum must be positive number.");
- }
- Balance -= sum;
- }
- }
- }
- using NUnit.Framework;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace UnitTesting.Tests
- {
- [TestFixture]
- public class BankAccountTest
- {
- [Test]
- public void TestNewBankAccount()
- {
- var bankAccount = new BanckAccount(100m);
- Assert.That(bankAccount.Balance, Is.EqualTo(100m),"Creating of new Bank Account");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment