public void CalculateOER()
        {
            IAccountingCalculator calc = new AccountingCalculator();
            decimal net = calc.CalculateOER(1000m, 500m);

            Assert.AreEqual(0.5m, net);
        }
Example #2
0
        public void CalculateProfit()
        {
            IAccountingCalculator calc = new AccountingCalculator();
            decimal net = calc.CalculateNet(1000m, 1000m);

            Assert.AreEqual(0m, net);
        }
Example #3
0
        protected void btnDisplayTotals_Click(object sender, EventArgs e)
        {
            try
            {
                decimal revenue  = decimal.Parse(txtRevenue.Text);
                decimal expenses = decimal.Parse(txtExpenses.Text);

                IAccountingCalculator calculator = new AccountingCalculator();
                decimal net = calculator.CalculateNet(revenue, expenses);

                litNet.Text = net.ToString("C");

                decimal oer = calculator.CalculateOER(revenue, expenses);
                litOer.Text = oer.ToString("P2");

                var maxOer = Convert.ToDecimal(ConfigurationManager.AppSettings["MaxAcceptableOER"]);

                if (oer > maxOer)
                {
                    litOer.CssClass = "badOer";
                }
                else
                {
                    litOer.CssClass = "goodOer";
                }

                pnlError.Visible = false;
            }
            catch
            {
                pnlError.Visible = true;
            }
        }
        private static AccountingCalculator GetCalculator(List <Person> persons)
        {
            var repository = new Mock <IPersonRepository>();

            repository.Setup(x => x.GetGraph()).Returns(persons);
            var calculator = new AccountingCalculator(repository.Object);

            return(calculator);
        }
        private static AccountingCalculator GetCalculator(Person person)
        {
            var repository = new Mock <IPersonRepository>();

            repository.Setup(x => x.GetPerson(It.IsAny <int>())).Returns(person);
            var calculator = new AccountingCalculator(repository.Object);

            return(calculator);
        }
Example #6
0
        protected void btnDisplayTotals_Click(object sender, EventArgs e)
        {
            try
            {
                decimal revenue  = decimal.Parse(txtRevenue.Text);
                decimal expenses = decimal.Parse(txtExpenses.Text);

                IAccountingCalculator calculator = new AccountingCalculator();
                decimal net = calculator.CalculateNet(revenue, expenses);

                litNet.Text      = net.ToString("C");
                pnlError.Visible = false;
            }
            catch
            {
                pnlError.Visible = true;
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            decimal?revenue  = null;
            decimal?expenses = null;

            if (args.Length == 2)
            {
                decimal r, e;
                revenue  = decimal.TryParse(args[0], out r) ? (decimal?)r : null;
                expenses = decimal.TryParse(args[1], out e) ? (decimal?)e : null;
            }

            if (revenue == null || expenses == null)
            {
                revenue  = PromptDecimal("Enter revenue: ");
                expenses = PromptDecimal("Enter expenses: ");
            }

            var     calculator = new AccountingCalculator();
            decimal profit     = calculator.CalculateNet(revenue.Value, expenses.Value);

            System.Console.WriteLine("Profit: " + profit.ToString("C2"));
        }
Example #8
0
 public void NegativeExpenses()
 {
     IAccountingCalculator calc = new AccountingCalculator();
     decimal net = calc.CalculateNet(1000m, -1000m);
 }
Example #9
0
 public void NegativeRevenue()
 {
     IAccountingCalculator calc = new AccountingCalculator();
     decimal net = calc.CalculateNet(-1000m, 1000m);
 }
 public void ZeroRevenueWhenCalculatingOER()
 {
     IAccountingCalculator calc = new AccountingCalculator();
     decimal net = calc.CalculateOER(0m, 1000m);
 }
Example #11
0
 public SalaryController(IMapper mapper, AccountingCalculator calculator)
 {
     this.mapper     = mapper;
     this.calculator = calculator;
 }