public virtual void TestValueTypes()
        {
            Verify(int.MaxValue);
            Verify(int.MinValue);
            NUnit.Framework.Assert.AreEqual(int.MaxValue, GenericObjectMapper.Read(GenericObjectMapper
                                                                                   .Write((long)int.MaxValue)));
            NUnit.Framework.Assert.AreEqual(int.MinValue, GenericObjectMapper.Read(GenericObjectMapper
                                                                                   .Write((long)int.MinValue)));
            Verify((long)int.MaxValue + 1l);
            Verify((long)int.MinValue - 1l);
            Verify(long.MaxValue);
            Verify(long.MinValue);
            NUnit.Framework.Assert.AreEqual(42, GenericObjectMapper.Read(GenericObjectMapper.
                                                                         Write(42l)));
            Verify(42);
            Verify(1.23);
            Verify("abc");
            Verify(true);
            IList <string> list = new AList <string>();

            list.AddItem("123");
            list.AddItem("abc");
            Verify(list);
            IDictionary <string, string> map = new Dictionary <string, string>();

            map["k1"] = "v1";
            map["k2"] = "v2";
            Verify(map);
        }
 private static void TestEncoding(long l)
 {
     byte[] b = GenericObjectMapper.WriteReverseOrderedLong(l);
     NUnit.Framework.Assert.AreEqual("error decoding", l, GenericObjectMapper.ReadReverseOrderedLong
                                         (b, 0));
     byte[] buf = new byte[16];
     System.Array.Copy(b, 0, buf, 5, 8);
     NUnit.Framework.Assert.AreEqual("error decoding at offset", l, GenericObjectMapper
                                     .ReadReverseOrderedLong(buf, 5));
     if (l > long.MinValue)
     {
         byte[] a = GenericObjectMapper.WriteReverseOrderedLong(l - 1);
         NUnit.Framework.Assert.AreEqual("error preserving ordering", 1, WritableComparator
                                         .CompareBytes(a, 0, a.Length, b, 0, b.Length));
     }
     if (l < long.MaxValue)
     {
         byte[] c = GenericObjectMapper.WriteReverseOrderedLong(l + 1);
         NUnit.Framework.Assert.AreEqual("error preserving ordering", 1, WritableComparator
                                         .CompareBytes(b, 0, b.Length, c, 0, c.Length));
     }
 }
Esempio n. 3
0
        public virtual void TestDeleteEntities()
        {
            NUnit.Framework.Assert.AreEqual(3, GetEntities("type_1").Count);
            NUnit.Framework.Assert.AreEqual(1, GetEntities("type_2").Count);
            NUnit.Framework.Assert.AreEqual(false, DeleteNextEntity(entityType1, GenericObjectMapper.WriteReverseOrderedLong
                                                                        (60l)));
            NUnit.Framework.Assert.AreEqual(3, GetEntities("type_1").Count);
            NUnit.Framework.Assert.AreEqual(1, GetEntities("type_2").Count);
            NUnit.Framework.Assert.AreEqual(true, DeleteNextEntity(entityType1, GenericObjectMapper.WriteReverseOrderedLong
                                                                       (123l)));
            IList <TimelineEntity> entities = GetEntities("type_2");

            NUnit.Framework.Assert.AreEqual(1, entities.Count);
            VerifyEntityInfo(entityId2, entityType2, events2, Sharpen.Collections.SingletonMap
                                 (entityType1, Sharpen.Collections.Singleton(entityId1b)), EmptyPrimaryFilters, EmptyMap
                             , entities[0], domainId1);
            entities = GetEntitiesWithPrimaryFilter("type_1", userFilter);
            NUnit.Framework.Assert.AreEqual(2, entities.Count);
            VerifyEntityInfo(entityId1b, entityType1, events1, EmptyRelEntities, primaryFilters
                             , otherInfo, entities[0], domainId1);
            // can retrieve entities across domains
            VerifyEntityInfo(entityId6, entityType1, EmptyEvents, EmptyRelEntities, primaryFilters
                             , otherInfo, entities[1], domainId2);
            ((LeveldbTimelineStore)store).DiscardOldEntities(-123l);
            NUnit.Framework.Assert.AreEqual(2, GetEntities("type_1").Count);
            NUnit.Framework.Assert.AreEqual(0, GetEntities("type_2").Count);
            NUnit.Framework.Assert.AreEqual(6, ((LeveldbTimelineStore)store).GetEntityTypes()
                                            .Count);
            ((LeveldbTimelineStore)store).DiscardOldEntities(123l);
            NUnit.Framework.Assert.AreEqual(0, GetEntities("type_1").Count);
            NUnit.Framework.Assert.AreEqual(0, GetEntities("type_2").Count);
            NUnit.Framework.Assert.AreEqual(0, ((LeveldbTimelineStore)store).GetEntityTypes()
                                            .Count);
            NUnit.Framework.Assert.AreEqual(0, GetEntitiesWithPrimaryFilter("type_1", userFilter
                                                                            ).Count);
        }
 /// <exception cref="System.IO.IOException"/>
 private static void Verify(object o)
 {
     NUnit.Framework.Assert.AreEqual(o, GenericObjectMapper.Read(GenericObjectMapper.Write
                                                                     (o)));
 }