private List<BondCalculatorModel> ReadTestInput(string testfile,bool expectYield)
        {
            List<BondCalculatorModel> inputs = new List<BondCalculatorModel>();

            using (StreamReader reader = File.OpenText(testfile))
            {
                CsvReader csv = new CsvReader(reader);
                while (csv.Read())
                {
                    BondCalculatorModel model = new BondCalculatorModel();

                    model.CouponRate = csv.GetField<decimal>(0);
                    model.YearsToMaturity = csv.GetField<int>(1);
                    model.Frequency = csv.GetField<int>(2);
                    model.FaceValue = csv.GetField<decimal>(3);
                    if (expectYield)
                    {
                        model.PresentValue = csv.GetField<decimal>(4);
                        model.Yield = csv.GetField<decimal>(5);
                    }
                    else
                    {
                        model.Yield = csv.GetField<decimal>(4);
                        model.PresentValue = csv.GetField<decimal>(5);
                    }

                    inputs.Add(model);
                }

            }
            return inputs;
        }
        public BondCalculatorViewModel()
        {
            //create model object
            calculatorModel = new BondCalculatorModel();

            //create calculation engine object using Unity container
            //we can register other types for this interface in unity and use here e.g. FincadCalculationEngine, BrentEngine
            calculationEngine = UnityFactory.Resolve<IBondCalculationEngine>("Default");

            //register event from model, will be raised when error state of model properties will change
            //will be used to enable/disable calculator button/radio button
            calculatorModel.NotifyVM = () => { NotifyPropertyChanged("ReadyForCalculation"); };

            //command that binds to Calculate button.
            CalculateCommand = new DelegateCommand(param => PriceBond(), (param) => ((ReadyForCalculation) && (!calculationRunning)));

            //capture action when user wants to switch from ComputeYield to ComputePV and vice-versa
            YieldToggleCommand = new DelegateCommand(param => {
                yieldGiven = (bool)param;
                StatusText = "";
                if (yieldGiven)
                {
                    calculatorModel.Yield = 0.0m;
                    calculatorModel.PresentValue = 0.0m;
                }
            }, (param) => true);

            PVToggleCommand = new DelegateCommand(param => {
                yieldGiven = !(bool)param;
                StatusText = "";
                if (!yieldGiven)
                {
                    calculatorModel.PresentValue = 0.0m;
                    calculatorModel.Yield = 0.0m;
                }
            }, (param) => true);
        }