コード例 #1
0
        internal void AddDollar(double PurchaseQuota, double QuotationSale, DateTime date)
        {
            var dollar = new Dollar(date, PurchaseQuota, QuotationSale);

            Ariary.Add(dollar);
            SaveAriary();
        }
コード例 #2
0
 public bool IsEligibleFor(Customer john, Dollar dollar)
 {
     return
         (this.bank.HasNotSufficientSavings(john, dollar) &&
          this.loan.HasNoBadLoans(john) &&
          this.credit.HasGoodCredit(john));
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Eschechola/DesignPatterns
        static void Main(string[] args)
        {
            ICurrency currency;
            double    valueToCalculate;
            double    calculatedValue;

            currency         = new Dollar();
            valueToCalculate = 5;
            calculatedValue  = currency.CalculateBRLQuote(valueToCalculate);

            Console.WriteLine("{0} dolares = {1} reais", valueToCalculate, calculatedValue);

            currency         = new Euro();
            valueToCalculate = 10;
            calculatedValue  = currency.CalculateBRLQuote(valueToCalculate);

            Console.WriteLine("{0} Euros = {1} reais", valueToCalculate, calculatedValue);

            currency         = new Libra();
            valueToCalculate = 20;
            calculatedValue  = currency.CalculateBRLQuote(valueToCalculate);

            Console.WriteLine("{0} Libras = {1} reais", valueToCalculate, calculatedValue);

            Console.ReadKey();
        }
コード例 #4
0
        public void TestFact01_Multiplication()
        {
            Money five    = new Dollar(5);
            Money product = five.Times(2);

            Assert.Equal(new Dollar(10), product);
        }
コード例 #5
0
        public string GetCurentDollarPrice()
        {
            Dollar currentValue = _uow.DollarRepo.GetCurrentDollarPrice();
            string result       = "buy:" + currentValue.BuyPrice + ",Sell:" + currentValue.SellPrice;

            return(result);
        }
コード例 #6
0
        public void TestEquality()
        {
            var dollar1 = new Dollar(5);
            var dollar2 = new Dollar(5);

            dollar1.Equals(dollar2).Should().Be(true);
        }
コード例 #7
0
        public decimal GetDollarSellPrice()
        {
            Dollar  currentValue = _uow.DollarRepo.GetCurrentDollarPrice();
            decimal ret          = _uow.DollarRepo.GetDollarSellPrice();

            return(ret);
        }
コード例 #8
0
        public void TestMultiplication()
        {
            var five    = new Dollar(5);
            var product = five.Times(2);

            product.Amount.Should().Be(10);
        }
コード例 #9
0
        public void TestMultiplication_Fact01()
        {
            Dollar five    = new Dollar(5);
            Dollar product = five.Times(2);

            Assert.Equal(10, product.Amount);
        }
コード例 #10
0
        public void TestMultiplication()
        {
            Dollar five = new Dollar(5);

            Assert.Equal(new Dollar(10), five.Times(2));
            Assert.Equal(new Dollar(15), five.Times(3));
        }
コード例 #11
0
        public void ProvideTheCorrectAnswerToAMultiplication()
        {
            var five = new Dollar(5);

            five.Times(2);
            Assert.Equal(10, five.Amount);
        }
コード例 #12
0
        internal void AddDollar(double cotacaoCompra, double cotacaoVenda, DateTime date)
        {
            var dollar = new Dollar(date, cotacaoCompra, cotacaoVenda);

            Dollares.Add(dollar);
            SaveDollares();
        }
コード例 #13
0
        public void testMultiplication()
        {
            Dollar five = new Dollar(5);

            five.Times(2);
            Assert.AreEqual(10, five.Amount);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            var dollar = new Dollar(20);

            dollar.getApple();  // output on screen: 100
            dollar.getBanana(); // output on screen: 200

            var apple = new Apple(5);

            apple.getDollar(); // output on screen: 1
            apple.getBanana(); // output on screen: 10

            var banana = new Banana(5);

            banana.getDollar(); // output on screen: 0.50
            banana.getApple();  // output on screen: 2.50

            dollar = new Dollar(0);
            dollar.getApple();

            apple = new Apple(-5);
            apple.getBanana();

            banana = new Banana("Hello");
            banana.getApple();
        }
コード例 #15
0
        public void testMultiplication()
        {
            Dollar five = Money.dollar(5);

            Assert.AreEqual(Money.dollar(10), five.times(2));
            Assert.AreEqual(Money.dollar(15), five.times(3));
        }
コード例 #16
0
        public void Should_pay_in_dollar()
        {
            IPayment payment = new Dollar {
            };
            Client client    = new Client(payment);
            Order  order     = new Order();

            CarBuilder builder = new PorscheBuilder();

            builder.createNewCar();
            builder.BuildBrand();
            builder.BuildColor();
            builder.BuildPrice();
            builder.BuildName();

            order.AddItem(builder.GetCar());
            order.NextStatus();
            order.NextStatus();


            string value = client.Pay(order);


            Assert.AreEqual("Vous avez payé un total de 96000 en Dollar  soit une somme de 120000 euro.", value);
        }
コード例 #17
0
        public ActionResult Get()
        {
            Dollar dollarPrice             = _uow.DollarRepo.GetCurrentDollarPrice();
            IEnumerable <GlobalPrice> data = _repo.GetData(dollarPrice.SellPrice);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #18
0
        public decimal GetGoldBuyPrice()
        {
            decimal goldPriceInDollar = _uow.GlobalPriceRepo.GetGoldBuyPrice();
            Dollar  dollarPrice       = _uow.DollarRepo.GetCurrentDollarPrice();
            decimal localGoldPrice    = Math.Round(goldPriceInDollar * dollarPrice.SellPrice, 2);

            return(localGoldPrice);
        }
コード例 #19
0
        public ActionResult Times(string userId, int multiplier)
        {
            Dollar dollar = _dollarService.GetSavings(userId);

            dollar.Amount *= multiplier;

            return(View(dollar));
        }
コード例 #20
0
        public bool SetAndGetShouldGiveSameResult(int amount)
        {
            var dollar = Dollar.Create(0);

            dollar.Add(amount);

            return(dollar.Amount == amount);
        }
コード例 #21
0
 public PurchasedMovie(Movie movie, Customer customer, Dollar price, ExpirationDate expirationDate)
 {
     Movie          = movie;
     Customer       = customer;
     Price          = price;
     ExpirationDate = expirationDate;
     PurchasedDate  = DateTime.UtcNow;
 }
コード例 #22
0
ファイル: Configuration.cs プロジェクト: oflores/confsamples
        protected override void Seed(MoneyContext context)
        {
            Dollar dollar1 = new Dollar {
                Id = "rodolfof", Amount = 5
            };

            context.Dollars.AddOrUpdate(d => d.Id, dollar1);
        }
コード例 #23
0
ファイル: DollarTest.cs プロジェクト: PoodleFather/TDD
        public void TestMulitiplication()
        {
            //Arrange
            Dollar five = new Dollar(5);

            //Assert
            Assert.AreEqual(new Dollar(10), five.Times(2));
            Assert.AreEqual(new Dollar(15), five.Times(3));
        }
コード例 #24
0
        public void testMultiplication()
        {
            Dollar five    = new Dollar(5);
            Dollar product = five.Times(2);

            Assert.AreEqual(10, product.Amount);
            product = five.Times(3);
            Assert.AreEqual(15, product.Amount);
        }
コード例 #25
0
        public void TestFact02_MultiplicationAndDegenerateObjects()
        {
            Dollar five    = new Dollar(5);
            Dollar product = five.Times(2);

            Assert.Equal(10, product.Amount);
            product = five.Times(3);
            Assert.Equal(15, product.Amount);
        }
コード例 #26
0
        public void CurrencyValueTests()
        {
            ICurrency penny  = new Penny();
            ICurrency dime   = new Dime();
            ICurrency dollar = new Dollar();

            Assert.AreEqual(.01m, penny.Value);
            Assert.AreEqual(.10m, dime.Value);
            Assert.AreEqual(1m, dollar.Value);
        }
コード例 #27
0
        public decimal GetDollarBuyPrice()
        {
            Dollar dollarPrice = _context.Dollar.OrderByDescending(x => x.ID).FirstOrDefault();

            if (dollarPrice != null)
            {
                return(dollarPrice.BuyPrice);
            }
            return(0.0m);
        }
コード例 #28
0
        public void CurrencyTest1()
        {
            ElectronicPayment ePayment = new ElectronicPayment(3.50m);

            Console.WriteLine(ePayment.Value);

            Dollar dollar = new Dollar();

            Assert.AreEqual(dollar.Value, 1.0m);
        }
コード例 #29
0
        public void testMultiplication()
        {
            // Arrange
            Dollar five = new Dollar(5);

            // Assert
            Assert.True(new Dollar(10).equals(five.times(2)));
            // Assert
            Assert.True(new Dollar(15).equals(five.times(3)));
        }
コード例 #30
0
        public void InjectingIntoConstructors()
        {
            var dollar            = new Dollar();
            var epayment          = new ElectronicPayment(52000m);
            var firstTransaction  = new Transaction(dollar);
            var secondTransaction = new Transaction(epayment);

            Console.WriteLine(firstTransaction.GetTransactionAmount());
            Console.WriteLine(secondTransaction.GetTransactionAmount());
        }
コード例 #31
0
    private Node sequence(Node end) {
        Node head = null;
        Node tail = null;
        Node node = null;
        for (;;) {
            int ch = peek();
            switch (ch) {
            case '(':
                // Because group handles its own closure,
                // we need to treat it differently
                node = group0();
                // Check for comment or flag group
                if (node == null)
                    continue;
                if (head == null)
                    head = node;
                else
                    tail.next = node;
                // Double return: Tail was returned in root
                tail = root;
                continue;
            case '[':
                node = clazz(true);
                break;
            case '\\':
                ch = nextEscaped();
                if (ch == 'p' || ch == 'P') {
                    boolean oneLetter = true;
                    boolean comp = (ch == 'P');
                    ch = next(); // Consume { if present
                    if (ch != '{') {
                        unread();
                    } else {
                        oneLetter = false;
                    }
                    node = family(oneLetter, comp);
                } else {
                    unread();
                    node = atom();
                }
                break;
            case '^':
                next();
                if (has(MULTILINE)) {
                    if (has(UNIX_LINES))
                        node = new UnixCaret();
                    else
                        node = new Caret();
                } else {
                    node = new Begin();
                }
                break;
            case '$':
                next();
                if (has(UNIX_LINES))
                    node = new UnixDollar(has(MULTILINE));
                else
                    node = new Dollar(has(MULTILINE));
                break;
            case '.':
                next();
                if (has(DOTALL)) {
                    node = new All();
                } else {
                    if (has(UNIX_LINES))
                        node = new UnixDot();
                    else {
                        node = new Dot();
                    }
                }
                break;
            case '|':
            case ')':
                goto end2;
            case ']': // Now interpreting dangling ] and } as literals
            case '}':
                node = atom();
                break;
            case '?':
            case '*':
            case '+':
                next();
                throw error(new String("Dangling meta character '" + ((char)ch) + "'"));
            case 0:
                if (_cursor >= patternLength) {
                    goto end2;
                }
                // Fall through
                node = atom();
                break;
            default:
                node = atom();
                break;
            }
            node = closure(node);
            if (head == null) {
                head = tail = node;
            } else {
                tail.next = node;
                tail = node;
            }
        }
end2:
        if (head == null) {
            return end;
        }
        tail.next = end;
        root = tail;      //double return
        return head;
    }