コード例 #1
0
        public virtual Dollars CalculatePrice(CustomerStatus status)
        {
            decimal modifier = 1 - status.GetDiscount();
            Dollars dollars  = GetBasePrice() * modifier;

            return(dollars);
        }
        public void Dollar_Convert_Number_to_Text()
        {
            string value  = Dollars.ConvertNumberToText(Convert.ToDecimal(785487)).ToString();
            string result = "seven hundred eighty five thousand four hundred eighty seven dollars";

            Assert.AreEqual(result.ToLower(), value.ToLower().Trim().Replace("  ", " "));
        }
コード例 #3
0
        public void SubtractTwoOthersCurrencies()
        {
            var first  = Dollars.Of(22.50);
            var second = Zloty.Of(22.50);

            Assert.Throws <ArgumentException>(() => first - second);
        }
コード例 #4
0
        public void TestDollarEquals()
        {
            var dollar1 = Dollars.Parse("5.00");
            var dollar2 = Dollars.Parse("5.00");

            Assert.IsTrue(dollar1.Equals(dollar2));
        }
コード例 #5
0
        public void Clear_Order()
        {
            Pennies              = 0;
            PenniesText.Text     = Pennies.ToString();
            Nickles              = 0;
            NicklesText.Text     = Nickles.ToString();
            Dimes                = 0;
            DimesText.Text       = Dimes.ToString();
            Quarters             = 0;
            QuartersText.Text    = Quarters.ToString();
            HalfDollars          = 0;
            HalfDollarsText.Text = HalfDollars.ToString();
            Dollars              = 0;
            DollarsText.Text     = Dollars.ToString();
            Ones              = 0;
            OnesText.Text     = Ones.ToString();
            Twos              = 0;
            TwosText.Text     = Twos.ToString();
            Fives             = 0;
            FivesText.Text    = Fives.ToString();
            Tens              = 0;
            TensText.Text     = Tens.ToString();
            Twenties          = 0;
            TwentiesText.Text = Twenties.ToString();
            Fifties           = 0;
            FiftiesText.Text  = Fifties.ToString();
            Hundreds          = 0;
            HundredsText.Text = Hundreds.ToString();

            TotalBox.Text = 0.00.ToString("C");
        }
コード例 #6
0
        public void TestMultiplicationInt()
        {
            var tenDollars = Dollars.Parse("10.00");
            var twoFifty   = Dollars.Parse("2.50");

            Assert.AreEqual(tenDollars, twoFifty * 4);
        }
コード例 #7
0
        public void TestMultiplicationDecimal()
        {
            var tenDollars = Dollars.Parse("10.00");
            var twoFifty   = Dollars.Parse("2.50");

            Assert.AreEqual(twoFifty, tenDollars * 0.25m);
        }
        public void Dollar_Convert_Text_to_Number()
        {
            string value  = Dollars.ConvertTextToNumber("seven hundred eighty five thousand four hundred eighty seven").ToString();
            string result = "785487";

            Assert.AreEqual(result, value);
        }
コード例 #9
0
        public void SubtractTwoDollarsTest(double first, double second, double result)
        {
            var firstDollar  = Dollars.Of(first);
            var secondDollar = Dollars.Of(second);
            var resultDollar = Dollars.Of(result);

            Assert.Equal(resultDollar, firstDollar - secondDollar);
        }
コード例 #10
0
        public void TestDollarGreaterThan()
        {
            var dollar1 = Dollars.Parse("1.00");
            var dollar2 = Dollars.Parse("2.00");

            Assert.IsTrue(dollar2 > dollar1);
            Assert.IsFalse(dollar1 > dollar2);
        }
コード例 #11
0
        public bool add()
        {
            var dollarRate  = Dollars.Parse(rate);
            var newEmployee = new Employee(id, name, payType, dollarRate);

            payroll.AddEmployee(newEmployee);
            return(true);
        }
コード例 #12
0
ファイル: Employee.cs プロジェクト: Hendricksonxp/ChetCsharp
 public Employee(string id, string name, string payType, Dollars payRate)
 {
     this.id      = id;
     this.name    = name;
     this.payType = payType;
     this.payRate = payRate;
     payments     = new Payments();
 }
コード例 #13
0
        public void PlusEqualsTest()
        {
            var dollar1 = Dollars.Parse("1.00");
            var dollar2 = Dollars.Parse("2.00");


            dollar2 += dollar1;
            Assert.AreEqual("3.00", dollar2.ToCleanString());
        }
コード例 #14
0
        public void TestAddition()
        {
            var fiveDollars  = Dollars.Parse("5.00");
            var twoDollars   = Dollars.Parse("2.00");
            var threeDollars = Dollars.Parse("3.00");
            var result       = threeDollars + twoDollars;

            Assert.AreEqual("5.00", result.ToCleanString());
            Assert.AreEqual(fiveDollars, result);
        }
コード例 #15
0
 private void Dollars_minus(object sender, RoutedEventArgs e)
 {
     if (Dollars - 1 < 0)
     {
         return;
     }
     Dollars--;
     DollarsText.Text = Dollars.ToString();
     TotalBox.Text    = Total.ToString("C");
 }
コード例 #16
0
 private void btnCalc_Click(object sender, EventArgs e)
 {
     if (txtvalue.Text == "")
     {
         lblSonuc.Text = "Lütfen Rakam belirtiniz.";
     }
     else
     {
         lblSonuc.Text = Dollars.ConvertNumberToText(Convert.ToDecimal(txtvalue.Text)).ToString();
     }
 }
コード例 #17
0
 private void btnDollarTtoN_Click(object sender, EventArgs e)
 {
     if (txtvalue_TtoN.Text == "")
     {
         lblSonuc_TtoN.Text = "Lütfen Yazı belirtiniz.";
     }
     else
     {
         lblSonuc_TtoN.Text = Dollars.ConvertTextToNumber(txtvalue_TtoN.Text).ToString();
     }
 }
コード例 #18
0
        public void SalaryTest()
        {
            Payroll  payroll = new Payroll();
            Dollars  payrate = Dollars.Parse("4000.00");
            Employee carl    = new Employee("1", "Carl", "Salary", payrate);

            payroll.AddEmployee(carl);

            var payDate = "01/31/2017";

            payroll.Pay(payDate);
            var payment = carl.GetPayment(payDate);

            Assert.AreEqual("1", carl.GetId());
            Assert.AreEqual("3,000.00", payment.GetNetPay().ToCleanString());
            Assert.AreEqual(1, payroll.PayCount());
            Assert.AreEqual("Carl", payroll.GetEmployee("1").GetName());
        }
コード例 #19
0
        public virtual Dollars CalculatePrice(AthleteStatus athleteStatus)
        {
            decimal discountModifyer = 1 - athleteStatus.GetDiscount();

            switch (LicensingModel)
            {
            case LicensingModelType.TwoDays:
                return(Dollars.Of(2) * discountModifyer);

            case LicensingModelType.ThirtyDays:
                return(Dollars.Of(4) * discountModifyer);

            case LicensingModelType.LifeLong:
                return(Dollars.Of(8) * discountModifyer);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #20
0
ファイル: Payroll.cs プロジェクト: Hendricksonxp/ChetCsharp
        public void PayEmployee(Employee employee)
        {
            Dollars basePay    = Dollars.Zero();
            var     grossPay   = Dollars.Zero();
            var     federalTax = Dollars.Zero();
            var     netPay     = Dollars.Zero();

            basePay   += employee.GetPayRate();
            grossPay  += basePay;
            federalTax = grossPay * FederalTaxRate();
            netPay     = grossPay - federalTax;

            var payment = new Payment(payDate, employee.GetId(), employee.GetName());

            payment.SetBasePay(basePay);
            payment.SetGrossPay(grossPay);
            payment.SetFederalTax(federalTax);
            payment.SetNetPay(netPay);
            employee.AddPayment(payment);
            _payCount++;
        }
コード例 #21
0
 public Dollars Minus(Dollars dollars)
 {
     return new Dollars(Amount - dollars.Amount);
 }
コード例 #22
0
 public Dollars Min(Dollars dollars)
 {
     return Amount <= dollars.Amount ? this : dollars;
 }
コード例 #23
0
 public Dollars Max(Dollars dollars)
 {
     return Amount >= dollars.Amount ? this : dollars;
 }
コード例 #24
0
 public bool IsGreaterThan(Dollars dollars)
 {
     return Amount > dollars.Amount;
 }
コード例 #25
0
 public Dollars(Dollars dollars)
 {
     Amount = dollars.Amount;
 }
コード例 #26
0
        public void TestDollarCreation()
        {
            var dollars = new Dollars(10.00m);

            Assert.AreEqual("10.00", dollars.ToCleanString());
        }
コード例 #27
0
        public void TestDollarParse()
        {
            var dollars = Dollars.Parse("5.00");

            Assert.AreEqual("5.00", dollars.ToCleanString());
        }
コード例 #28
0
        public void should_fail_to_create_invalid_amount_of_cents()
        {
            Result <Dollars> dollar = Dollars.Create(1.11111m);

            dollar.IsFailure.Should().BeTrue();
        }
コード例 #29
0
ファイル: Payment.cs プロジェクト: Hendricksonxp/ChetCsharp
 public void SetFederalTax(Dollars amount)
 {
     federalTax = amount;
 }
コード例 #30
0
 public Dollars Plus(Dollars dollars)
 {
     return new Dollars(Amount + dollars.Amount);
 }
コード例 #31
0
 private void Dollars_add(object sender, RoutedEventArgs e)
 {
     Dollars++;
     DollarsText.Text = Dollars.ToString();
     TotalBox.Text    = Total.ToString("C");
 }
コード例 #32
0
 protected bool Equals(Dollars other)
 {
     return Amount.ToString("0.00").Equals(other.Amount.ToString("0.00"));
 }
コード例 #33
0
ファイル: Payment.cs プロジェクト: Hendricksonxp/ChetCsharp
 public void SetNetPay(Dollars amount)
 {
     netPay = amount;
 }
コード例 #34
0
 public void CreateTwoPointPrecisionWithThreePointPrecisionNumberTest()
 {
     Assert.Throws <ArgumentException>(() => Dollars.Of(10.501));
 }
コード例 #35
0
        public void CreateDollarsTest(double value)
        {
            CurrencyValue dollars = Dollars.Of(value);

            Assert.Equal(value, dollars);
        }
コード例 #36
0
 protected override Dollars GetBasePrice()
 {
     return(Dollars.Of(8));
 }
コード例 #37
0
 public void CreateTwoPointPrecisionWitNegativeNumberTest()
 {
     Assert.Throws <ArgumentException>(() => Dollars.Of(-10));
 }