public void Must_Throws_Invalid_Call_Option_Exception() { BlackScholesInput blackScholesInput = _fileReaderMock.GetOne(); blackScholesInput.Cp = 'M'; _blackScholesCalculator.CalculateFor(blackScholesInput); }
public void Must_Import_Data_And_Calculate_For_Csv(FileReaderTypeEnum fileReaderTypeEnum, string extension) { IFileReader reader = FileReaderFactory.GetReader(fileReaderTypeEnum); List <BlackScholesInput> blackScholesInputData = reader.Read <BlackScholesInput>($"{FullPath}{extension}"); var optionPricingCalculator = new BlackScholesCalculator(); List <BlackScholesResult> blackScholesResultData = optionPricingCalculator.CalculateFor(blackScholesInputData); List <double> expectedResults = new List <double>() { 110, 30, 0, 0, 110, 1.2444594168143162E-196, 110, 0 }; List <double> results = optionPricingCalculator.CalculateFor(blackScholesInputData).Select(r => r.Result).ToList(); CollectionAssert.AreEqual(expectedResults, results); }
private void btnInputFile_Click(object sender, EventArgs e) { DialogResult result = openFileDialogCsv.ShowDialog(); if (result == DialogResult.OK) { try { FileReaderTypeEnum fileReaderTypeEnum = GetFileReaderTypeFor(openFileDialogCsv.FileName); IFileReader reader = FileReaderFactory.GetReader(fileReaderTypeEnum); List <BlackScholesInput> blackScholesInputData = reader.Read <BlackScholesInput>(openFileDialogCsv.FileName); var optionPricingCalculator = new BlackScholesCalculator(); List <BlackScholesResult> blackScholesResultData = optionPricingCalculator.CalculateFor(blackScholesInputData); ShowResultsOnScreen(blackScholesResultData); } catch (Exception ex) { string message = $"{ErrorsResource.ErrorToProcessData} Error: {ex.Message}"; MessageBox.Show(message, ErrorsResource.TitleErrorToProcessData, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }