예제 #1
0
        public void TestClear()
        {
            NamedMultiset            set  = new NamedMultiset();
            Dictionary <string, int> data = set.ToDictionary();

            Assert.AreEqual(0, data.Count);

            set.Add("item1");
            set.Add("item2");

            data = set.ToDictionary();
            Assert.AreEqual(2, data.Count);

            set.Clear();
            data = set.ToDictionary();
            Assert.AreEqual(0, data.Count);
        }
예제 #2
0
        public void TestIsSubsetOf()
        {
            NamedMultiset set1 = new NamedMultiset {
                "item1", "item2"
            };
            NamedMultiset set2 = new NamedMultiset {
                "item1"
            };

            Assert.IsTrue(set2.IsSubsetOf(set1));
            Assert.IsFalse(set1.IsSubsetOf(set2));

            set1.Add("item1");
            Assert.IsTrue(set2.IsSubsetOf(set1));
        }
예제 #3
0
        public void TestEquals()
        {
            NamedMultiset set1 = new NamedMultiset {
                "item1"
            };
            NamedMultiset set2 = new NamedMultiset {
                "item1"
            };

            Assert.IsTrue(set1.Equals(set2));

            NamedMultiset set3 = new NamedMultiset();

            Assert.IsFalse(set1.Equals(set3));

            set1.Add("item1");
            Assert.IsFalse(set1.Equals(set2));
        }
예제 #4
0
 /// <summary>
 /// Deserialize given XML list of signal objects.
 /// </summary>
 /// <param name="glueTuples">XML element list of glue tuples.</param>
 /// <exception cref="MissingXmlAttribute">If some attribute of floating object is missing.</exception>
 /// <exception cref="MissingXmlElement">If some element of floating object is missing.</exception>
 private void DeserializeSignalObjects(List <XElement> glueTuples)
 {
     foreach (XElement glueTuple in glueTuples)
     {
         string        nameOfTheGlue1      = Xmlizer.GetAttributeValueWithException(glueTuple, "glueTuple", "glue1");
         string        nameOfTheGlue2      = Xmlizer.GetAttributeValueWithException(glueTuple, "glueTuple", "glue2");
         NamedMultiset signalObjects       = new NamedMultiset();
         XElement      objectElement       = glueTuple.Element("objects");
         List <string> floatingObjectNames = Xmlizer.GetAttributeValueWithException(objectElement, "objects", "value").Split(',').ToList();
         foreach (string floatingObjectName in floatingObjectNames)
         {
             if (!FloatingObjects.ContainsKey(floatingObjectName))
             {
                 throw new InvalidOperationException(string.Format("Floating object named '{0}' is not defined in input xml file.",
                                                                   floatingObjectName));
             }
             signalObjects.Add(floatingObjectName);
         }
         //TODO check if it find correct value
         GluePRelation[new Tuple <Glue, Glue>(Glues[nameOfTheGlue1], Glues[nameOfTheGlue2])] = signalObjects;
     }
 }