Ejemplo n.º 1
0
        public void AddAndGetGappedMnvRefCount()
        {
            var stateManager = new RegionStateManager(false);

            // -----------------------------------------------
            // happy path - add a couple of counts in different blocks,
            // getting them should return the same
            // -----------------------------------------------

            Dictionary <int, int> refCounts = new Dictionary <int, int>();

            refCounts.Add(25, 10);
            refCounts.Add(250, 15);
            refCounts.Add(25000, 20);

            stateManager.AddGappedMnvRefCount(refCounts);
            Assert.Equal(10, stateManager.GetGappedMnvRefCount(25));
            Assert.Equal(15, stateManager.GetGappedMnvRefCount(250));
            Assert.Equal(20, stateManager.GetGappedMnvRefCount(25000));

            // -----------------------------------------------
            // adding to existing values - unmentioned/zeroed ones should remain the same
            // -----------------------------------------------
            Dictionary <int, int> moreRefCounts = new Dictionary <int, int>();

            moreRefCounts.Add(25, 3);
            moreRefCounts.Add(25000, 0);
            moreRefCounts.Add(500, 10);

            stateManager.AddGappedMnvRefCount(moreRefCounts);
            Assert.Equal(13, stateManager.GetGappedMnvRefCount(25));
            Assert.Equal(15, stateManager.GetGappedMnvRefCount(250));
            Assert.Equal(20, stateManager.GetGappedMnvRefCount(25000));
            Assert.Equal(10, stateManager.GetGappedMnvRefCount(500));
        }