public void TestRandomBlockTagSerializaton() { SimpleTagsIndex tagsIndex = new SimpleTagsIndex(); SimpleTagsCollection tagsCollection = new SimpleTagsCollection(); for (int i = 0; i < 100; i++) { int tagCollectionSize = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10) + 1; for (int idx = 0; idx < tagCollectionSize; idx++) { int tagValue = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10); tagsCollection.Add( string.Format("key_{0}", tagValue), string.Format("value_{0}", tagValue)); } uint tagsId = tagsIndex.Add(tagsCollection); } ITagsIndexReadonly tagsIndexReadonly = this.SerializeDeserializeBlock(tagsIndex, 10, 0); Assert.AreEqual(tagsIndex.Max, tagsIndexReadonly.Max); for (uint idx = 0; idx < tagsIndex.Max; idx++) { this.CompareTagsCollections(tagsIndex.Get(idx), tagsIndexReadonly.Get(idx)); } }
public void TestSimpleTagSerializatonNonBeginPosition() { SimpleTagsIndex tagsIndex = new SimpleTagsIndex(); SimpleTagsCollection tagsCollection = new SimpleTagsCollection(); tagsCollection.Add("key1", "value1"); uint tagsId = tagsIndex.Add(tagsCollection); ITagsIndexReadonly tagsIndexReadonly = this.SerializeDeserialize(tagsIndex, 1201); Assert.AreEqual(tagsIndex.Max, tagsIndexReadonly.Max); for (uint idx = 0; idx < tagsIndex.Max; idx++) { this.CompareTagsCollections(tagsIndex.Get(idx), tagsIndexReadonly.Get(idx)); } }
public void TestRandomPartialTagSerializaton() { SimpleTagsIndex tagsIndex = new SimpleTagsIndex(); SimpleTagsCollection tagsCollection = new SimpleTagsCollection(); for (int i = 0; i < 100; i++) { int tagCollectionSize = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10) + 1; for (int idx = 0; idx < tagCollectionSize; idx++) { int tagValue = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10); tagsCollection.Add( string.Format("key_{0}", tagValue), string.Format("value_{0}", tagValue)); } uint tagsId = tagsIndex.Add(tagsCollection); } uint from = 40; uint to = 50; ITagsIndexReadonly tagsIndexReadonly = this.SerializeDeserialize(tagsIndex, from, to); Assert.AreEqual(System.Math.Min(to, tagsIndex.Max), tagsIndexReadonly.Max); for (uint idx = 0; idx < tagsIndex.Max; idx++) { if (idx >= from && idx < to) { this.CompareTagsCollections(tagsIndex.Get(idx), tagsIndexReadonly.Get(idx)); } else { Assert.IsNull(tagsIndexReadonly.Get(idx)); } } from = 0; to = 100; tagsIndexReadonly = this.SerializeDeserialize(tagsIndex, from, to); Assert.AreEqual(System.Math.Min(to, tagsIndex.Max), tagsIndexReadonly.Max); for (uint idx = 0; idx < tagsIndex.Max; idx++) { if (idx >= from && idx < to) { this.CompareTagsCollections(tagsIndex.Get(idx), tagsIndexReadonly.Get(idx)); } else { Assert.IsNull(tagsIndexReadonly.Get(idx)); } } from = 10; to = 1000; tagsIndexReadonly = this.SerializeDeserialize(tagsIndex, from, to); Assert.AreEqual(System.Math.Min(to, tagsIndex.Max), tagsIndexReadonly.Max); for (uint idx = 0; idx < tagsIndex.Max; idx++) { if (idx >= from && idx < to) { this.CompareTagsCollections(tagsIndex.Get(idx), tagsIndexReadonly.Get(idx)); } else { Assert.IsNull(tagsIndexReadonly.Get(idx)); } } }