public void ConstructorTest()
        {
            _considerations.Clear();
            var c = ConsiderationConstructor.Chebyshev("name", _considerations);

            Assert.That(_considerations.Contains("name"));
        }
        public void ConsiderTest(
            [Range(0.0f, 10.0f, 2.5f)] float xval1,
            [Range(0.0f, 10.0f, 2.5f)] float xval2)
        {
            // NEVER use the derived class to call
            // Consider otherwise the machinery in the base
            // class is never called!
            var c = ConsiderationConstructor.Chebyshev();

            var cd1 = new OptionConsideration1();
            var cd2 = new OptionConsideration2();

            cd1.NameId = "cd1";
            cd2.NameId = "cd2";
            c.AddConsideration(cd1);
            c.AddConsideration(cd2);
            _optionContext.XVal1 = xval1;
            _optionContext.XVal2 = xval2;
            cd1.Consider(_optionContext);
            cd2.Consider(_optionContext);
            var cUtil1 = cd1.Utility;
            var cUtil2 = cd2.Utility;
            var cUtilL = new List <Utility>();

            cUtilL.Add(cUtil1);
            cUtilL.Add(cUtil2);
            var cNorm = cUtilL.Chebyshev();

            c.Consider(_optionContext);
            Assert.That(c.Utility.Value, Is.EqualTo(cNorm).Within(Tolerance));
        }
        public void ConstructorTest()
        {
            var c = ConsiderationConstructor.Chebyshev();

            Assert.IsNotNull(c);
            Assert.That(c.Weight, Is.EqualTo(1.0f).Within(Tolerance));
        }
        public void ChebyshevConstructor()
        {
            var c = ConsiderationConstructor.Chebyshev();

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.Measure);
            Assert.That(c.Measure is Chebyshev);
        }
        public void CloneHasSameNameIdTest()
        {
            _considerations.Clear();
            var c  = ConsiderationConstructor.Chebyshev("name", _considerations);
            var cc = c.Clone();

            Assert.That(c.NameId == cc.NameId);
        }
        public void EmptyOrNullConsiderationIdNotAcceptableTest()
        {
            _considerations.Clear();
            var c = ConsiderationConstructor.Chebyshev("name", _considerations);

            Assert.That(c.AddConsideration("") == false);
            Assert.That(c.AddConsideration((string)null) == false);
        }
        public void EnsureSameInstanceConsiderationIsNotAddedTest()
        {
            _considerations.Clear();
            var c  = ConsiderationConstructor.Chebyshev("name", _considerations);
            var b1 = new BasicConsideration("b1", _considerations);

            Assert.That(c.AddConsideration(b1));
            Assert.That(c.AddConsideration(b1) == false);
        }
        public void EnsureSettingDefaultUtilityAlsoSetsUtilityTest()
        {
            _considerations.Clear();
            var c = ConsiderationConstructor.Chebyshev("name", _considerations);

            c.DefaultUtility = new Utility(0.4f, 0.5f);
            Assert.AreEqual(c.DefaultUtility.Value, c.Utility.Value);
            Assert.AreEqual(c.DefaultUtility.Weight, c.Utility.Weight);
        }
        public void EnsureNullIsNotAcceptedByMeasureTest()
        {
            _considerations.Clear();
            var c = ConsiderationConstructor.Chebyshev("name", _considerations);

            Assert.IsNotNull(c.Measure);
            c.Measure = null;
            Assert.IsNotNull(c.Measure);
        }
        public void SameNameIdIsNotAddedTest()
        {
            _considerations.Clear();
            var c  = ConsiderationConstructor.Chebyshev("name", _considerations);
            var b1 = new BasicConsideration("b1", _considerations);

            Assert.That(c.AddConsideration("b1"));
            Assert.That(c.AddConsideration("b1") == false);
        }
        public void ChebyshevWithNameConstructor()
        {
            var cc = new ConsiderationCollection();
            var c  = ConsiderationConstructor.Chebyshev("name", cc);

            Assert.IsNotNull(c);
            Assert.IsNotNull(c.Measure);
            Assert.That(c.Measure is Chebyshev);
            Assert.That(cc.Contains("name"));
        }
        public void CloneHasCollectionTest()
        {
            _considerations.Clear();
            var c  = ConsiderationConstructor.Chebyshev("name", _considerations);
            var cc = c.Clone() as ICompositeConsideration;
            var b1 = new BasicConsideration("b1", _considerations);

            Assert.That(c.AddConsideration("b1"));
            Assert.That(cc.AddConsideration("b1"));
        }
        public void ThrowsNameIdAlreadyExistsTest()
        {
            _considerations.Clear();
            var c1 = ConsiderationConstructor.Chebyshev("name", _considerations);

            Assert.Throws <CompositeConsideration.NameIdAlreadyExistsInCollectionException>(
                () =>
                ConsiderationConstructor
                .Chebyshev("name",
                           _considerations));
        }
        public void EnsureCloneHasConsiderationsTest()
        {
            _considerations.Clear();
            var c  = ConsiderationConstructor.Chebyshev("name", _considerations);
            var b1 = new BasicConsideration("b1", _considerations);
            var b2 = new BasicConsideration("b2", _considerations);

            c.AddConsideration("b1");
            c.AddConsideration("b2");
            var cc = c.Clone() as ICompositeConsideration;

            Assert.That(cc.AddConsideration("b1") == false);
            Assert.That(cc.AddConsideration("b2") == false);
        }