public void EnumerationTest1()
        {
            var samples1_1000 = Sample1.GenerateSamples(1000);
            EnumerationFinder <Sample1> finder = new EnumerationFinder <Sample1>(samples1_1000);

            finder.GenerateEnumeration(x => x.Category);
            finder.GenerateEnumeration(x => x.CategoryId);
            finder.GenerateEnumeration(x => x.Manager);

            var enumerationList = finder.EnumerationList;

            Schema schema = finder.Schema;

            Assert.AreEqual(enumerationList.Enumerations.Count(), 3);
            Assert.IsTrue(enumerationList.Enumerations[schema.KeyMap[nameof(Sample1.Category)].NewKey].Count() <= 6);
            Assert.IsTrue(enumerationList.Enumerations[schema.KeyMap[nameof(Sample1.CategoryId)].NewKey].Count() <= 6);
            Assert.IsTrue(enumerationList.Enumerations[schema.KeyMap[nameof(Sample1.Manager)].NewKey].Count() <= 10);
        }
Пример #2
0
        public void TestCompression1()
        {
            var samples1_1000 = Sample1.GenerateSamples(100000);
            //TestSample1Sanity(1000, samples1_1000);

            Stopwatch w = new Stopwatch();

            w.Start();
            EnumerationFinder <Sample1> finder = new EnumerationFinder <Sample1>(samples1_1000);

            finder.GenerateEnumeration(x => x.Category);
            finder.GenerateEnumeration(x => x.CategoryId);
            finder.GenerateEnumeration(x => x.Manager);

            var packedData = DataCompressor <Sample1> .Compress(samples1_1000, finder.Schema, finder.EnumerationList);

            w.Stop();
            var elapsedMillis = w.Elapsed.TotalMilliseconds;

            var originalJson   = JsonUtils.ConvertToJson(samples1_1000).ToCharArray().Length;
            var compressedJson = JsonUtils.ConvertToJson(packedData).ToCharArray().Length;

            Assert.IsNotNull(packedData);
        }