Ejemplo n.º 1
0
        /// <summary>
        ///     List of exchange rates configured for the currency.
        /// </summary>
        /// <param name="currency_id">
        ///     The currency_id is the identifier of the currency which is configuered with the exchange
        ///     rates.
        /// </param>
        /// <param name="parameters">
        ///     The parameters is the Dictionary object which conrains the filters in the form of key,value pair to refine the
        ///     list.<br></br>The possible filters are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>from_date</td>
        ///             <td>
        ///                 Returns the exchange rate details from the given date or from previous closest match in the absence of
        ///                 the exchange rate on the given date.
        ///             </td>
        ///         </tr>
        ///         <tr>
        ///             <td>is_current_date</td><td>To return the exchange rate only if available for current date.</td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>List of ExchangeRate objects.</returns>
        public ExchangeRateList GetExchangeRates(string currency_id, Dictionary <object, object> parameters)
        {
            var url      = baseAddress + "/currencies/" + currency_id + "/exchangerates";
            var response = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(CurrencyParser.getExchangeRateList(response));
        }
        public void CurrencyParserReturnsCurrencyObjWithCorrectStackSize()
        {
            var      cp = new CurrencyParser(PoEItemData.Currency.EXALTED_ORB);
            Currency c  = cp.Parse();

            Assert.AreEqual(9, c.StackSize);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Get the details of a currency.
        /// </summary>
        /// <param name="currency_id">The currency_id is the identifier of the currency.</param>
        /// <returns>Currency object.</returns>
        public Currency GetACurrency(string currency_id)
        {
            var url      = baseAddress + "/currencies/" + currency_id;
            var response = ZohoHttpClient.get(url, getQueryParameters());

            return(CurrencyParser.getCurrency(response));
        }
Ejemplo n.º 4
0
        //-------------------------------------------------------------------------------

        /// <summary>
        ///     List of configured currencies with pagination.
        /// </summary>
        /// <param name="parameters">
        ///     The parameters is the Dictionary object which conrains the filters in the form of key,value pair to refine the
        ///     list.<br></br>The possible filters are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>filter_by</td>
        ///             <td>
        ///                 Filter list of configured currencies excluding the base currency<br></br>Allowed Values:
        ///                 <i>Currencies.ExcludeBaseCurrency</i>
        ///             </td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>CurrenciesList object.</returns>
        public CurrencyList GetCurrencies(Dictionary <object, object> parameters)
        {
            var url      = baseAddress + "/currencies";
            var response = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(CurrencyParser.getCurrencyList(response));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Get the details of an exchange rate that has been associated to the currency.
        /// </summary>
        /// <param name="currency_id">The currency_id is the identifier of the currency.</param>
        /// <param name="exchange_rate_id">
        ///     The exchange_rate_id is the exchange rate identifier which associated with the specified
        ///     currency.
        /// </param>
        /// <returns>ExchangeRate object.</returns>
        public ExchangeRate GetAnExchangeRate(string currency_id, string exchange_rate_id)
        {
            var url      = baseAddress + "/currencies/" + currency_id + "/exchangerates/" + exchange_rate_id;
            var response = ZohoHttpClient.get(url, getQueryParameters());

            return(CurrencyParser.getExchangeRate(response));
        }
Ejemplo n.º 6
0
 public Item ToDomain()
 {
     return(new Item(Id)
     {
         Description = Description,
         Price = Money.From(Price, CurrencyParser.TryParse(Currency))
     });
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            string connectionString = LoadConnectionString();

            CurrencyParser parser  = CreateCurrencyParser(connectionString);
            ICommand       command = parser.Parse(args);

            command.Execute();
        }
 public void ParseNullWillReturnCorrectResult(CurrencyParser sut)
 {
     // Fixture setup
     // Exercise system
     ICommand result = sut.Parse(null);
     // Verify outcome
     Assert.IsAssignableFrom<HelpCommand>(result);
     // Teardown
 }
 public void ParseEmptyArgsWillReturnCorrectResult(CurrencyParser sut)
 {
     // Fixture setup
     // Exercise system
     var result = sut.Parse(Enumerable.Empty<string>());
     // Verify outcome
     Assert.IsAssignableFrom<HelpCommand>(result);
     // Teardown
 }
Ejemplo n.º 10
0
        public void ParseEmptyArgsWillReturnCorrectResult(CurrencyParser sut)
        {
            // Fixture setup
            // Exercise system
            var result = sut.Parse(Enumerable.Empty <string>());

            // Verify outcome
            Assert.IsAssignableFrom <HelpCommand>(result);
            // Teardown
        }
Ejemplo n.º 11
0
        public void ParseNullWillReturnCorrectResult(CurrencyParser sut)
        {
            // Fixture setup
            // Exercise system
            ICommand result = sut.Parse(null);

            // Verify outcome
            Assert.IsAssignableFrom <HelpCommand>(result);
            // Teardown
        }
Ejemplo n.º 12
0
 public void ParseSingleArgWillReturnCorrectResult(CurrencyParser sut)
 {
     // Fixture setup
     var arg = "DKK";
     // Exercise system
     var result = sut.Parse(new[] { arg });
     // Verify outcome
     Assert.IsAssignableFrom<HelpCommand>(result);
     // Teardown
 }
 public ItemDtoValidator()
 {
     RuleFor <string>(i => i.Description).Length(10, 3000)
     .WithMessage("{PropertyName}'s length must be between {MinLength} and {MaxLength}");
     RuleFor <decimal>(i => i.Price).GreaterThan(0);
     RuleFor(i => CurrencyParser.TryParse(i.Currency))
     .NotEqual(Currency.Nothing)
     .WithName("Currency")
     .WithMessage("{PropertyName} has an unknown value.");
 }
Ejemplo n.º 14
0
        public void ParseSingleArgWillReturnCorrectResult(CurrencyParser sut)
        {
            // Fixture setup
            var arg = "DKK";
            // Exercise system
            var result = sut.Parse(new[] { arg });

            // Verify outcome
            Assert.IsAssignableFrom <HelpCommand>(result);
            // Teardown
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Creates a currency for transactions.
        /// </summary>
        /// <param name="new_currency_info">The new_currency_info is the currency info with the currency_code,currency_symbol and currency_format as the mandatory attributes.</param>
        /// <returns>Currency object.</returns>
        public Currency CreateCurrency(Currency new_currency_info)
        {
            string url        = baseAddress + "/currencies";
            var    json       = JsonConvert.SerializeObject(new_currency_info);
            var    jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var response = ZohoHttpClient.post(url, getQueryParameters(jsonstring));

            return(CurrencyParser.getCurrency(response));
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Update the details of a currency.
        /// </summary>
        /// <param name="currency_id">The currency_id is the identifier of the currency.</param>
        /// <param name="update_info">The update_info is the currency object which contains the updation information.</param>
        /// <returns>Currency object.</returns>
        public Currency UpdateCurrency(string currency_id, Currency update_info)
        {
            var url        = baseAddress + "/currencies/" + currency_id;
            var json       = JsonConvert.SerializeObject(update_info);
            var jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var response = ZohoHttpClient.put(url, getQueryParameters(jsonstring));

            return(CurrencyParser.getCurrency(response));
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Update the details of exchange rate for a currency.
        /// </summary>
        /// <param name="currency_id">The currency_id is the identifier of the currency.</param>
        /// <param name="exchange_rate_id">
        ///     The exchange_rate_id is the identifier of the exchange rate which is configured for the
        ///     specified currency.
        /// </param>
        /// <param name="update_info">The update_info is the ExchangeRate object which contains the updation information.</param>
        /// <returns>ExchangeRate object.</returns>
        public ExchangeRate UpdateAnExchangeRate(string currency_id, string exchange_rate_id, ExchangeRate update_info)
        {
            var url        = baseAddress + "/currencies/" + currency_id + "/exchangerates/" + exchange_rate_id;
            var json       = JsonConvert.SerializeObject(update_info);
            var jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var response = ZohoHttpClient.put(url, getQueryParameters(jsonstring));

            return(CurrencyParser.getExchangeRate(response));
        }
Ejemplo n.º 18
0
        public void ResolveCurrencyParserWillReturnInstance()
        {
            // Fixture setup
            var fixture = new CurrencyFixture();
            var sut     = fixture.CreateAnonymous <CurrencyContainer>();
            // Exercise system
            CurrencyParser result = sut.ResolveCurrencyParser();

            // Verify outcome
            Assert.IsNotNull(result, "ResolveCurrencyParser");
            // Teardown
        }
Ejemplo n.º 19
0
 void OnTextChanged()
 {
     unselectedBox.Clear();
     if (selectedBox.Text != string.Empty)
     {
         try
         {
             string currency1    = selectedBox == CurrencyTextBox1 ? CurrencyComboBox1.Text : CurrencyComboBox2.Text;
             string currency2    = selectedBox == CurrencyTextBox1 ? CurrencyComboBox2.Text : CurrencyComboBox1.Text;
             double exchangeRate = CurrencyParser.getExchangeRate(currency1, currency2);
             unselectedBox.AppendText($"{Math.Round(double.Parse(selectedBox.Text) * exchangeRate, 4)}");
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
         }
     }
 }
        public ItemDto Update(Guid id, ItemDto itemDto)
        {
            var item = itemRepository.GetById(id);

            if (item == null)
            {
                return(null);
            }

            //stupid thing because EF. Semes that this will not be needed iin EF core 2.1.0
            itemRepository.PrepareForUpdate(item.Price);

            item.Description = itemDto.Description;
            item.Price       = Money.From(itemDto.Price, CurrencyParser.TryParse(itemDto.Currency));

            itemRepository.UpdateItem(item);
            unitOfWork.Commit();

            return(ItemDto.FromDomain(item));
        }
Ejemplo n.º 21
0
        public void ParseValidArgsWillReturnCorrectResult(decimal rate, Mock <Currency> currencyStub, [Frozen] Mock <CurrencyProvider> currencyProviderStub, CurrencyParser sut)
        {
            // Fixture setup
            var srcCurrencyArg  = "EUR";
            var destCurrencyArg = "USD";
            var rateArg         = rate.ToString();

            currencyStub.Setup(c => c.Code).Returns(srcCurrencyArg);

            currencyProviderStub.Setup(cp => cp.GetCurrency(srcCurrencyArg)).Returns(currencyStub.Object);

            var expectedResult = new Likeness <CurrencyUpdateCommand, CurrencyUpdateCommand>(new CurrencyUpdateCommand(currencyStub.Object, destCurrencyArg, rate));
            // Exercise system
            var result = sut.Parse(new[] { destCurrencyArg, srcCurrencyArg, rateArg });

            // Verify outcome
            Assert.True(expectedResult.Equals(result));
            // Teardown
        }
Ejemplo n.º 22
0
        public void ParseValidArgsWillReturnCorrectResult(decimal rate, Mock<Currency> currencyStub, [Frozen]Mock<CurrencyProvider> currencyProviderStub, CurrencyParser sut)
        {
            // Fixture setup
            var srcCurrencyArg = "EUR";
            var destCurrencyArg = "USD";
            var rateArg = rate.ToString();

            currencyStub.Setup(c => c.Code).Returns(srcCurrencyArg);

            currencyProviderStub.Setup(cp => cp.GetCurrency(srcCurrencyArg)).Returns(currencyStub.Object);

            var expectedResult = new Likeness<CurrencyUpdateCommand, CurrencyUpdateCommand>(new CurrencyUpdateCommand(currencyStub.Object, destCurrencyArg, rate));
            // Exercise system
            var result = sut.Parse(new[] { destCurrencyArg, srcCurrencyArg, rateArg });
            // Verify outcome
            Assert.True(expectedResult.Equals(result));
            // Teardown
        }