// 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; } }
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."); }
// 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))); }; }
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); }
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); }
public Adapter() { _adaptee = new Adaptee(); }