コード例 #1
0
ファイル: Adapter.cs プロジェクト: Letractively/henoch
 // Different constructors for the expected targets/adaptees
 // Adapter-Adaptee
 // ReSharper disable UnusedParameter.Local
 /// <summary>
 /// The Adeptee feature will be altered.
 /// </summary>
 /// <param name="adaptee"></param>
 
 public Adapter(Adaptee adaptee)
 // ReSharper restore UnusedParameter.Local
 {
     m_NormCdf = ((double arg) => new Distributions().NormCdf(arg));
     // Set the delegate to the new standard
     if (adaptee != null)
     {
         m_Distributions = adaptee;
     }
 }
コード例 #2
0
ファイル: AdapterTest.cs プロジェクト: Letractively/henoch
        public void NormCdfTest()
        {
            new NormalDistribution(0, 1);
            //matlabResult = 0.682689492137086;

            Adaptee adaptee = new Adaptee(); 
            Adapter target = new Adapter(adaptee); 
            Func<double, double> expected = adaptee.NormCdf; 
            Func<double, double> actual;
            actual = target.NormCdf;
            Assert.AreNotEqual(expected, actual,  "Adaptee should be adapted.") ;

            Func<double, double> otherFunction = arg =>
                                             {
                                                 arg = arg - 1;
                                                 return arg;
                                             };
            Assert.AreNotEqual(expected, otherFunction);
            ///Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #3
0
 // Different constructors for the   expected targets/adaptees
 public Adapter(Adaptee adaptee)
 {
     // Set the delegate to the new standard
     Request = delegate(int i) { return("Estimate based on precision is " + (int)Math.Round(Precise(i, 3))); };
 }
コード例 #4
0
ファイル: AdapterTest.cs プロジェクト: Letractively/henoch
        public void AdapterConstructorAdapteeTest()
        {
            Adaptee adaptee = new Adaptee();
            Adapter target = new Adapter(adaptee);

            //Assert.IsFalse(target.Distributions is Distributions);
            //Assert.AreEqual(target.Distributions , new Distributions());
           
            Func<double, double> expected = adaptee.NormCdf;
            Func<double, double> actual = target.NormCdf;
            Assert.AreNotEqual(expected(1), actual(1), "Should NOT be equal function behaviour.");
            

            Func<double, double> otherFunction = arg =>
            {
                arg = arg - 1;
                return arg;
            };
            Assert.AreNotEqual(expected, otherFunction);
        }
コード例 #5
0
ファイル: AdapterTest.cs プロジェクト: Letractively/henoch
        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);
        }
コード例 #6
0
 public Adapter()
 {
     _adaptee = new Adaptee();
 }