예제 #1
0
        public void AdapterConstructorTargetTest()
        {
            Distributions target1 = new Distributions();
            Adapter target = new Adapter(target1);
            Adaptee adaptee = new Adaptee();
            NormalDistribution normCdf = new NormalDistribution(0, 1);

            Func<double, double> expected = target1.NormCdf;
            Func<double, double> actual = target.NormCdf;
            
            Assert.AreNotEqual(expected(1), adaptee.NormCdf(1), "Should NOT be equal function behaviour.");
            Assert.AreEqual(expected(1), actual(1), "Should be equal function behaviour.");
            Assert.AreEqual( normCdf.CumulativeDistribution(1), actual(1), "Should be equal function behaviour.");

            Func<double, double> normCdf2 = arg =>
            {
                arg = arg - 1;
                return arg;
            };
            Assert.AreNotEqual(expected, normCdf2);
        }
예제 #2
0
        public void AdapterGetDistribTest()
        {
            Distributions target1 = new Distributions();
            Adapter target = new Adapter(target1);
            ///Adaptee adaptee = new Adaptee();

            Assert.AreEqual(target.NormCdf(1), target1.NormCdf(1), 1.0E-8);

            target = new Adapter();
            Assert.AreEqual(1, target.NormCdf(1), 1.0E-8);
        }
예제 #3
0
        /// <summary>
        ///  Adapter-Target
        /// </summary>
        /// <param name="target"></param>

        public Adapter(Distributions target)
        {
            // Set the delegate to the existing standard
            //Request = (arg => target.Estimate(arg));
            m_NormCdf = ((double arg) => new Distributions().NormCdf(arg));
            m_Distributions = target;
        }