public ActionResult Convertion(NumberViewModel number) { var result = new WordResultViewModel(); if (ModelState.IsValid) { result.ValueWord = _conserterService.Convert(number.ValueDouble); } return(PartialView(result)); }
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)); } }
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)); }
public void Test1CelciusToFahrenheit() { var far = service.Convert("Celcius", "Fahrenheit", 10); Assert.IsTrue(far.ToValue == 50); }