Ejemplo n.º 1
0
        public void TestBasics()
        {
            var tags = new HaystackDictionary();

            tags.Add("id", new HaystackReference("aaaa-bbbb"));
            tags.Add("site", new HaystackMarker());
            tags.Add("geoAddr", new HaystackString("Richmond, Va"));
            tags.Add("area", new HaystackNumber(1200, "ft"));
            tags.Add("date", new HaystackDate(2000, 12, 3));
            tags.Add("null", null);

            // size
            Assert.AreEqual(5, tags.Count);
            Assert.IsFalse(tags.IsEmpty());

            // configured tags
            Assert.IsTrue(tags.Get("id").Equals(new HaystackReference("aaaa-bbbb")));
            Assert.IsTrue(tags.Get("site").Equals(new HaystackMarker()));
            Assert.IsTrue(tags.Get("geoAddr").Equals(new HaystackString("Richmond, Va")));
            Assert.IsTrue(tags.Get("area").Equals(new HaystackNumber(1200, "ft")));
            Assert.IsTrue(tags.Get("date").Equals(new HaystackDate(2000, 12, 3)));
            Assert.ThrowsException <HaystackUnknownNameException>(() => tags.Get("null"));

            // missing tag
            Assert.IsFalse(tags.ContainsKey("foo"));
            Assert.ThrowsException <HaystackUnknownNameException>(() => tags.Get("foo"));
        }
 private ZincWriter WriteMeta(HaystackDictionary meta)
 {
     if (meta.IsEmpty())
     {
         return(this);
     }
     WriteValue(' ');
     return(WriteDictionary(meta));
 }
Ejemplo n.º 3
0
        public void TestEmpty()
        {
            // Instance Empty
            var tags = new HaystackDictionary();

            Assert.AreEqual(tags, new HaystackDictionary());

            // size
            Assert.AreEqual(tags.Count, 0);
            Assert.IsTrue(tags.IsEmpty());

            // missing tag
            Assert.IsFalse(tags.ContainsKey("foo"));
        }