Example #1
0
        public void testBasics()
        {
            HRow row = BuildRows(
                new[] { "id", "site", "geoAddr", "area", "date", "null" },
                new HVal[] { HRef.make("aaaa-bbbb"), HMarker.VAL, HStr.make("Richmond, Va"), HNum.make(1200, "ft"), HDate.make(2000, 12, 3), null })
                       .First();

            // size
            Assert.AreEqual(row.size(), 6);
            Assert.IsFalse(row.isEmpty());

            // configured tags
            Assert.IsTrue(row.get("id").hequals(HRef.make("aaaa-bbbb")));
            Assert.IsTrue(row.get("site").hequals(HMarker.VAL));
            Assert.IsTrue(row.get("geoAddr").hequals(HStr.make("Richmond, Va")));
            Assert.IsTrue(row.get("area").hequals(HNum.make(1200, "ft")));
            Assert.IsTrue(row.get("date").hequals(HDate.make(2000, 12, 3)));
            Assert.AreEqual(row.get("null", false), null);
            try
            {
                row.get("null");
                Assert.Fail();
            }
            catch (HaystackUnknownNameException)
            {
                Assert.IsTrue(true);
            }

            // missing tag
            Assert.IsFalse(row.has("foo"));
            Assert.IsTrue(row.missing("foo"));
            Assert.IsNull(row.get("foo", false));
            try { row.get("foo"); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); }
            try { row.get("foo", true); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); }
        }
Example #2
0
        public void testEmpty()
        {
            // Instance Empty
            HRow row = BuildRows(Array.Empty <string>(), Array.Empty <HVal>()).First();

            Assert.AreEqual(row, HRow.Empty);

            // size
            Assert.AreEqual(row.size(), 0);
            Assert.IsTrue(row.isEmpty());

            // missing tag
            Assert.IsFalse(row.has("foo"));
            Assert.IsTrue(row.missing("foo"));
            Assert.IsNull(row.get("foo", false));
        }