Beispiel #1
0
        public void Actual(DataTestCase testCase)
        {
            Data.InitMarketData(testCase.Vol,
                                testCase.Rate,
                                testCase.EvalDate);

            var            pricingCfg      = new PricingConfiguration(testCase.GreekTypes);
            var            pricer          = new Pricer();
            PricingResults expectedResults = null;
            var            actualResults   = pricer.Results(testCase.Option, pricingCfg);
            var            error           = string.Empty;

            try
            {
                using (StreamReader file = File.OpenText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    expectedResults = (PricingResults)serializer.Deserialize(file, typeof(PricingResults));
                }
            }
            catch (Exception e)
            {
                Assert.Fail(error = string.Format("Not Deserialize result: {0}", e.Message));
            }

            if (actualResults.CompareResult(expectedResults))
            {
                Assert.Pass("No regression detected");
            }
            else
            {
                // save ecart
                Assert.Fail("regression detected");
            }
        }
Beispiel #2
0
        public void Reference(DataTestCase testCase)
        {
            Data.InitMarketData(testCase.Vol,
                                testCase.Rate,
                                testCase.EvalDate);

            var pricingCfg  = new PricingConfiguration(testCase.GreekTypes);
            var pricer      = new Pricer();
            var results     = pricer.Results(testCase.Option, pricingCfg);
            var json        = JsonConvert.SerializeObject(results, Formatting.Indented);
            var msg         = "The reference is generated";
            var isGenereted = true;

            try
            {
                using (StreamWriter file =
                           File.CreateText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, results);
                }
            }
            catch (Exception e)
            {
                isGenereted = false;
                msg         = string.Format("The reference cannot be generated:{0}", e.Message);
            }
            finally
            {
                if (isGenereted == false)
                {
                    Assert.Fail(msg);
                }
                else
                {
                    Assert.Pass(msg);
                }
            }
        }