public IActionResult Index(ConversaoViewModel model, string de, string para, string valor) { var retorno = new ConversionController().currencyConversion(de, para, Convert.ToDouble(valor)); model.CurrenciesList = new ConversionController().currenciesList(); TempData["resultado"] = retorno; return(View(model)); }
public void Test_IfCollectionIsNull_ThrowsException() { // Arrange const string[] inputArray = null; CultureInfo currentCulture = CultureInfo.CurrentCulture; ConversionController converted = new ConversionController(currentCulture); // Assert Assert.Throws <ArgumentNullException>(() => converted.ProcessInputArray(inputArray)); }
public void NullConverter_ThrowsArgumentNullException() { var mockFileRepository = new Mock <IFileRepository>(); var mockPdfWriter = new Mock <IPdfWriter>(); var inputDir = "notempty"; var conversionController = new ConversionController(mockFileRepository.Object); conversionController.Run(inputDir, null, mockPdfWriter.Object); }
public void EmptyInputDir_ThrowsArgumentException() { var mockFileRepository = new Mock <IFileRepository>(); var mockPdfWriter = new Mock <IPdfWriter>(); var mockConverter = new Mock <ITextToPdfConverter>(); var inputDir = ""; var conversionController = new ConversionController(mockFileRepository.Object); conversionController.Run(inputDir, mockConverter.Object, mockPdfWriter.Object); }
public void GetTestPassTest() { //Arrange controller = new ConversionController(this._captureNumber.Object); //Act var response = controller.Get("John", "Smith", "12.44"); //Assert Assert.AreEqual("twelve dollars and fourty four cents", response.AmountinText); Assert.AreEqual("John", response.FirstName); Assert.AreEqual("Smith", response.LastName); Assert.AreEqual(12.44, response.Amount); }
public void ConvertNumtoAlphaTest() { Mock <IConvertAmount> convertAmtObj = new Mock <IConvertAmount>(); ConversionController conversionControllerObj = new ConversionController(convertAmtObj.Object); PersonDetail personDetails = new PersonDetail(); personDetails.Name = "Hemant"; personDetails.Amount = "123"; var result = conversionControllerObj.ConvertNumtoAlpha(personDetails) as JsonResult; var mockResult = GetTestPersonDetails(); Assert.AreEqual(result.Data, mockResult.Data); }
public void Test2ToUnits() { // Arrange var mockservice = new Mock <IConverterService>(); var mockhttp = new Mock <IHttpContextAccessor>(); mockservice.Setup(serv => serv.GetToUnits("Inch")).Returns(GetUnits()); var controller = new ConversionController(mockservice.Object, mockhttp.Object); // Act var result = (JsonContent)controller.ToUnits("Inch"); // Assert Assert.IsTrue(result.Content.Equals("[\"Centimeters\",\"Meters\"]")); }
public void GetTestFailTest() { //Arrange controller = new ConversionController(this._captureNumber.Object); //Act try { var response = controller.Get(null, null, " "); } catch (Exception ex) { //Assert Assert.AreEqual("Input string was not in a correct format.", ex.Message); } }
public void ConvertNumberZero() { ConversionController controller = new ConversionController(); decimal inputNumber = 0.0M; string expectedOutput = "zero"; string result = controller.ConvertToWords(inputNumber); // Assert if the result is NULL Assert.IsNotNull(result); // Assert if the result is not equal to input value Assert.AreNotEqual(inputNumber, result); // Asset if the result matches the expected output Assert.AreEqual(expectedOutput, result); }
public void ConvertNumberMillions() { ConversionController controller = new ConversionController(); decimal inputNumber = 1234561.89M; string expectedOutput = "one million two hundred and thirty-four thousand five hundred and sixty-one dollars and eighty-nine cents"; string result = controller.ConvertToWords(inputNumber); // Assert if the result is NULL Assert.IsNotNull(result); // Assert if the result is not equal to input value Assert.AreNotEqual(inputNumber, result); // Asset if the result matches the expected output Assert.AreEqual(expectedOutput, result); }
public void ConvertNumberHundreds() { ConversionController controller = new ConversionController(); decimal inputNumber = 123.45M; string expectedOutput = "one hundred and twenty-three dollars and forty-five cents"; string result = controller.ConvertToWords(inputNumber); // Assert if the result is NULL Assert.IsNotNull(result); // Assert if the result is not equal to input value Assert.AreNotEqual(inputNumber, result); // Asset if the result matches the expected output Assert.AreEqual(expectedOutput, result); }
public void Run_ConvertsNTimes() { //assign var mockFileRepository = new Mock <IFileRepository>(); var mockPdfWriter = new Mock <IPdfWriter>(); var mockConverter = new Mock <ITextToPdfConverter>(); var inputDir = "not used"; var lines = new string[] { ".large\n", "Hello\n", ".bold\n", "World!" }; mockFileRepository.Setup(p => p.GetLines(inputDir)).Returns(lines); var conversionController = new ConversionController(mockFileRepository.Object); //act conversionController.Run(inputDir, mockConverter.Object, mockPdfWriter.Object); //assert mockConverter.Verify(mock => mock.Convert(It.IsAny <string>()), Times.Exactly(4)); }
public void ConvertNumtoAlphaTest() { Mock <IConvertAmount> convertAmtObj = new Mock <IConvertAmount>(); PersonDetail personDetails = new PersonDetail(); personDetails.Name = "Hemant"; personDetails.Amount = "123"; PersonDetail personDetailsMock = new PersonDetail() { Name = "Hemant", Amount = "one hundred and twenty three dollar" }; convertAmtObj.Setup(x => x.ConvertAmountToAplha(personDetails)).Returns(personDetailsMock); ConversionController conversionControllerObj = new ConversionController(convertAmtObj.Object); var result = conversionControllerObj.ConvertNumtoAlpha(personDetails) as JsonResult; Assert.AreEqual(200, GetVal <int>(result, "StatusCode")); Assert.AreEqual("Hemant", GetVal <PersonDetail>(result, "outPut").Name); Assert.AreEqual("one hundred and twenty three dollar", GetVal <PersonDetail>(result, "outPut").Amount); }
public void Test3ConvertUnits() { // Arrange var mockservice = new Mock <IConverterService>(); var mockhttp = new Mock <IHttpContextAccessor>(); mockservice.Setup(serv => serv.Convert("Inch", "Centimeter", 8)).Returns(new Library.Models.ConversionModel { FromUnit = "Inch", ToUnit = "Centimeter", Rate = 0.4, FromValue = 10, Type = "Length", ToValue = 4 }); var controller = new ConversionController(mockservice.Object, mockhttp.Object); // Act var result = (JsonContent)controller.Convert("Inch", "Centimeter", "8"); // Assert Assert.IsTrue(result.Content.Equals("4.0")); }
public ConversionControllerTest() { controller = new ConversionController(); }