Esempio n. 1
0
        public ActionResult Convertion(NumberViewModel number)
        {
            var result = new WordResultViewModel();

            if (ModelState.IsValid)
            {
                result.ValueWord = _conserterService.Convert(number.ValueDouble);
            }

            return(PartialView(result));
        }
Esempio n. 2
0
        public async Task <ConvertResult> Index(ConvertViewModel convertViewModel)
        {
            if (!ModelState.IsValid)
            {
                return new ConvertResult()
                       {
                           IsSuccessfull = false
                       }
            }
            ;

            return(await convertService.Convert(convertViewModel.Amount, convertViewModel.From, convertViewModel.To));
        }
    }
Esempio n. 3
0
        public void ConvertCorrectlyCalculates(double amountToConvert, string originalCurrency, string targetCurrency, double convertedAmount)
        {
            // Arrange
            var fakeRatios = new List <CurrencyConversionRatio>
            {
                new CurrencyConversionRatio()
                {
                    OriginalCurrency = "GBP", TargetCurrency = "FOO", Ratio = 0.10
                },
                new CurrencyConversionRatio()
                {
                    OriginalCurrency = "GBP", TargetCurrency = "BAR", Ratio = 20.00
                }
            };

            _repository.Setup(x => x.GetConversionRatios()).Returns(fakeRatios);
            _service = new ConverterService(_repository.Object);

            // Act
            var result = _service.Convert(amountToConvert, originalCurrency, targetCurrency);

            // Assert
            Assert.That(result, Is.EqualTo(convertedAmount));
        }
Esempio n. 4
0
        public void Test1CelciusToFahrenheit()
        {
            var far = service.Convert("Celcius", "Fahrenheit", 10);

            Assert.IsTrue(far.ToValue == 50);
        }