public void EqualsTest()
        {
            var elementA = new FuzzyElement { X = 6, Value = 0.33 };
            var elementB = new FuzzyElement { X = 6, Value = 0.33 };

            Assert.IsTrue(elementA.Equals(elementB));
            Assert.IsTrue(elementA == elementB);
            Assert.IsFalse(elementA != elementB);
            Assert.IsTrue(elementA.GetHashCode() == elementB.GetHashCode());

            var elementC = new FuzzyElement { X = 6, Value = 0.31 };

            Assert.IsFalse(elementA.Equals(elementC));
            Assert.IsFalse(elementA == elementC);
            Assert.IsTrue(elementA != elementC);
            Assert.IsFalse(elementA.GetHashCode() == elementC.GetHashCode());
        }
Esempio n. 2
0
 /// <summary>
 /// Add a new Fuzzy element
 /// </summary>
 /// <param name="x">Value in the universe of discourse</param>
 public void Add(double x)
 {
     var element = new FuzzyElement { X = x, Value = this.CalculateMembershipDegree(x) };
     this.Elements.Add(element.X, element);
 }
        public void ToStringTest()
        {
            var element = new FuzzyElement { X = 6, Value = 0.33 };

            Assert.AreEqual(element.ToString(), "0.33/6");
        }